I''m a bit of a n00b, so my problem is more that I can''t figure out the last step from other posts. I want to launch some controller methods in application.rb from a script, so I''m trying to use the console to help write it. ?> require "app/controllers/application.rb" => true>> ApplicationController.post_render(:id => 119)NoMethodError: undefined method `post_render'' for ApplicationController:Class from (irb):5>> ApplicationController.instance_methods=> ["methods", "web_service_object", "render_nothing".........................."post_render", ............................. "gem", "transition", "silence_stream"] What really silly thing am I doing wrong? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Jonathan, Jonathan Dobbie wrote:> I want to launch some controller methods in application.rb< from a script, so I''m trying to use the console to help write it.> ?> require "app/controllers/application.rb" > => trueIt looks like you might be using irb rather than the console. irb is just Ruby. script/console loads your development (i.e., Rails) environment. hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jonathan :> I want to launch some controller methods in application.rb > from a script, so I''m trying to use the console to help write it. > > ?> require "app/controllers/application.rb" > => trueyou don''t have to require it in script/console.> >> ApplicationController.post_render(:id => 119) > NoMethodError: undefined method `post_render'' for > ApplicationController:Class > from (irb):5 > > >> ApplicationController.instance_methods > => ["methods", "web_service_object", > "render_nothing".........................."post_render", > ............................. "gem", "transition", "silence_stream"] > > What really silly thing am I doing wrong?#post_render is an instance method and you''re invoking it as a class method, so it doesn''t work :) If you want to test your action in script/console, call it as if it were a browser : app.get ''my_url'' (like app.get ''article/show/2'' ) and inspect it : app.response.body app.controller.params ... -- Jean-François. -- Ruby ( http://www.rubyfrance.org ) on Rails ( http://www.railsfrance.org ) --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bill Walton wrote:> Hi Jonathan, > > Jonathan Dobbie wrote: > >> I want to launch some controller methods in application.rb > < from a script, so I''m trying to use the console to help write it. > >> ?> require "app/controllers/application.rb" >> => true > > It looks like you might be using irb rather than the console. irb is > just > Ruby. script/console loads your development (i.e., Rails) environment.I''m using whatever loads when, from the ruby root directory I run `script/console` I''m using: #!/usr/bin/env ruby RAILS_ENV = ''development'' require File.dirname(__FILE__) + ''/../config/environment'' as the header to the final script (which appears to give me a very similar environment to the console) The ''require'' line does appear to be redundant though. My methods are in instance_methods, but not in methods, if that helps. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> > (like app.get ''article/show/2'' ) > > and inspect it : > > app.response.body > app.controller.params > ...Is there another way to do it? I''m using .htaccess files to tie authentication to our LDAP servers and I just get 401s -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---