Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running rake task on 'production' and specifying environment?

Tags:

I have a host at Linode and am trying to run a Rake task on it, but I get a mySQL error saying it can't connect. It looks like it thinks it is on dev. I did some Googling and saw that I can do something like this:

bundle exec rails c 

It loads the dev environment and I can't run User.all giving me an access denied error.

If I run bundle exec rails c RAILS_ENV=production I get the error:

Rails.env=production database is not configured (ActiveRecord::AdapterNotSpecified) 

However, if I access it via the web, everything is OK. I was able to run rake db:seed before so I know that there's some way around this.

Accessing mySQL with the production credentials works fine.

Any ideas?

like image 454
timpone Avatar asked Feb 04 '12 01:02

timpone


People also ask

How do I run a rake task environment?

Go to Websites & Domains and click Ruby. After gems installation you can try to run a Rake task by clicking Run rake task. In the opened dialog, you can provide some parameters and click OK - this will be equivalent to running the rake utility with the specified parameters in the command line.

Where do I put rake tasks?

rake extension and are placed in Rails. root/lib/tasks . You can create these custom rake tasks with the bin/rails generate task command. If your need to interact with your application models, perform database queries and so on, your task should depend on the environment task, which will load your application code.

How do I list a rake task?

You can get a list of Rake tasks available to you, which will often depend on your current directory, by typing rake --tasks . Each task has a description, and should help you find the thing you need.


1 Answers

Try this:

rails c production 

or, at the beginning:

RAILS_ENV=production rails c 

It thinks you're passing RAILS_ENV=production as an argument when you put it at the end.

like image 193
Nick Colgan Avatar answered Sep 22 '22 05:09

Nick Colgan