Is there an easy 'command line/console' way of checking if a Rails app is connecting properly to MySQL?
Unfortunately, I can't get a Rails console to come up. It complains about:
/home/nexargi/www/gi/vendor/ruby/1.9.1/gems/activerecord-3.2.1/lib
/active_record/dynamic_matchers.rb:50:in `method_missing': undefined
local variable or method `abddadhocbkgid' for #<Class:0x000000036427f8> (NameError)
from /home/nexargi/www/gi/app/models/adhoc_bkg_diners_diet.rb:5:in
`<class:AdhocBkgDinersDiet>'.
The 'abddadhocbkid' is the first attribute of the first table and therefore I am thinking that it is not managing to connect to the mysql database. I need to find a way of checking if Rails can connect to the mysql database without logging into the rails console.
Here is my model code:
class AdhocBkgDinersDiet < ActiveRecord::Base
validates_presence_of :abddadhocbkgid, :abddmealdietid, :abddadultnos, :abddchildnos
validates_numericality_of :abddadultnos, :abddchildnos, greater_than_or_equal_to: 0
belongs_to :adhoc_bkg, foreign_key:abddadhocbkgid
belongs_to :meal_diet, foreign_key: :abddmealdietid
end
If you just need to check if your connection is active after it has been established, there is the ActiveRecord::Base.connected?
method.
You can try connecting directly using console:
ActiveRecord::Base.establish_connection(
Rails.configuration.database_configuration[Rails.env]
)
Or if you have a model you can try finding one:
SomeModel.first
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With