Hi... I trying to make this example work: http://www.misuse.org/science/2007/07/24/firing-rails-controller-actions-from-command-line-console/ I need it for sending out emails and doing a lot of other tasks from a specific action in a controller. The error I get is: rake actions:echo rake aborted! A key is required to write a cookie containing the session data. Use config.action_controller.session = { :key => "_myapp_session", :secret => "some secret phrase" } in config/environment.rb Also require ''action_controller/integration'' doesn''t work but require ''action_controller'' does but yields the error above. I''ve tried to specify a key generated through rake secret but still no luck trying to make it work. Any help is much appreciated.
Tyler Jennings
2009-Oct-31 05:45 UTC
Re: Firing Rails Controller Actions From Command Line Console
I''m sorry if this derails your question, but it would be much better to factor the code so that the behavior your want to invoke is not tied up in the execution of the action. You might have heard smart people say Fat Model Skinny Controller<http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model> . It is exceptionally good advice. When you have done this, there are facilities for invoking your models from the command line that are built right into rails. I suggest you investigate the use of custom rake tasks<http://railsenvy.com/2007/6/11/ruby-on-rails-rake-tutorial> for this purpose. The road you''re on now is a perilous one. This fellow you linked to is using the rails integration testing framework to do his dirty deeds (that is the ''require action_controller/integration'' line). Okay if you''re messing around, not okay for doing real work. -Tyler On Sat, Oct 31, 2009 at 12:30 AM, Katherine <bridgeutopia-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi... > I trying to make this example work: > > > http://www.misuse.org/science/2007/07/24/firing-rails-controller-actions-from-command-line-console/ > > I need it for sending out emails and doing a lot of other tasks from a > specific action in a controller. > > The error I get is: > > rake actions:echo > > rake aborted! > A key is required to write a cookie containing the session data. Use > config.action_controller.session = { :key => "_myapp_session", :secret > => "some secret phrase" } in config/environment.rb > > > Also require ''action_controller/integration'' doesn''t work but require > ''action_controller'' does but yields the error above. > > I''ve tried to specify a key generated through rake secret but still no > luck trying to make it work. > Any help is much appreciated. > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Katherine
2009-Oct-31 14:08 UTC
Re: Firing Rails Controller Actions From Command Line Console
The controller action is not that fat. It''s just 3 lines which uses Notifier model to send a bunch of links like password reset url, login url and all that. There are realy no other tasks aside from sending out emails. So perhaps if it''s easier to just try Firing model methods than controller actions, how do you pass urls from a model?
Katherine
2009-Oct-31 14:21 UTC
Re: Firing Rails Controller Actions From Command Line Console
Anyway... I''ve figured out the problem, Thanks.
JDevine
2009-Nov-01 19:31 UTC
Re: Firing Rails Controller Actions From Command Line Console
If you have time, please share your solution. I had a similar problem a while back, and ended up just using ActionMailer and creating a mail object and extracting the body. Other solutions required too much including different ActionView and ActionController modules ad nauseum. On Oct 31, 8:21 am, Katherine <bridgeuto...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Anyway... I''ve figured out the problem, Thanks.