Lee Mallabone
2009-Jan-29 16:26 UTC
[Facebooker-talk] link_to issue when running outside of web server
Hi all, I''ve created a class that I want to run outside of my web server using the standard rails "script/runner". The script works fine, loading ActiveRecord objects etc, until I try and use the link_to helper. I''ve included the following in my class: include ActionView::Helpers::UrlHelper include ActionController::UrlWriter but when I try and call link_to I get the following error: /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/url_rewriter.rb:138:in `url_for'': Missing host to link to! Please provide :host parameter or set default_url_options[:host] (RuntimeError) I''m calling link_to like this: link_to(''link test'', :canvas => true, :controller => :job, :action => :show, :id => user_job) It almost looks as though facebooker''s URL helper methods are not getting mixed in properly, so it''s not picking up facebooker''s host or canvas prefix. Anyone know how to fix this? I''ve attached a tiny class that demonstrates the problem in my environment. run it with: script/runner /path/to/link_to_issue.rb Regards, Lee. -- Lee Mallabone. Crossbone Systems Ltd. Tired of hunting for great people? Post jobs on your facebook profile with Head Hunting: http://apps.facebook.com/headhunting/pages/recruiter -------------- next part -------------- A non-text attachment was scrubbed... Name: link_to_issue.rb Type: text/x-ruby-script Size: 230 bytes Desc: not available URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20090129/68d4cc4f/attachment.bin>
Mike Mangino
2009-Jan-29 19:01 UTC
[Facebooker-talk] link_to issue when running outside of web server
There is a lot of magic required to make those helpers work. You will probably need to include the facebooker helpers. The Publisher code sets up a class with all of the helpers available, you might try looking at that. Mike On Jan 29, 2009, at 11:26 AM, Lee Mallabone wrote:> Hi all, > > I''ve created a class that I want to run outside of my web server using > the standard rails "script/runner". > > The script works fine, loading ActiveRecord objects etc, until I try > and use the link_to helper. > > I''ve included the following in my class: > include ActionView::Helpers::UrlHelper > include ActionController::UrlWriter > but when I try and call link_to I get the following error: > > /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ > url_rewriter.rb:138:in > `url_for'': Missing host to link to! Please provide :host parameter or > set default_url_options[:host] (RuntimeError) > > I''m calling link_to like this: > link_to(''link test'', :canvas => true, :controller => :job, :action => > :show, :id => user_job) > > It almost looks as though facebooker''s URL helper methods are not > getting mixed in properly, so it''s not picking up facebooker''s host or > canvas prefix. Anyone know how to fix this? I''ve attached a tiny class > that demonstrates the problem in my environment. run it with: > script/runner /path/to/link_to_issue.rb > > Regards, > Lee. > > -- > Lee Mallabone. > Crossbone Systems Ltd. > > Tired of hunting for great people? > Post jobs on your facebook profile with Head Hunting: > http://apps.facebook.com/headhunting/pages/recruiter > <link_to_issue.rb>_______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk-- Mike Mangino http://www.elevatedrails.com