Reputation: 4867
I ran my rails app correctly with rails s -e production
, but when I run rails generate scaffold Campaign title:string owner:string
I get
/Users/myhome/vendor/bundle/ruby/2.0.0/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect': Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Why is it so ? apache is correctly running since the app is running
Upvotes: 0
Views: 95
Reputation: 906
I think you have specified the socket only
in production section in database.yml
.
When you do rails generate..
it will be run in development
environment. So it is not able to connect to mysql database. Also while you are developing, there is no need to run the app in production
mode. You can just use rails s
to run it in development mode.
On a side note, on the production server, you will have to specify the production environment like this
RAILS_ENV=production rails generate ..
Upvotes: 2