Hi, when the "Agile Web Development" book talks about routes, there are what looks like console transcripts like the following: URL> store @params = {:controller => ''store'', :action = ''index''} Is there something like a console for testing routes (where you could put in a url and see how rails would route it)?? Ingo -- Posted via http://www.ruby-forum.com/.
I''m pretty sure that dave just created that for demonstration purposes but the latest rails as the app object in the console which you can use for this: ./script/console>> app.url_for :controller => ''store'', :action => ''index''=> "http://www.example.com/store">> app.host! ''www.snowdevil.ca''=> "www.snowdevil.ca">> app.url_for :controller => ''store'', :action => ''index''=> "http://www.snowdevil.ca/store" On 4/4/06, Ingo Weiss <ingoweiss@gmail.com> wrote:> Hi, > > when the "Agile Web Development" book talks about routes, there are what > looks like console transcripts like the following: > > URL> store > @params = {:controller => ''store'', :action = ''index''} > > Is there something like a console for testing routes (where you could > put in a url and see how rails would route it)?? > > Ingo > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tobi http://shopify.com - modern e-commerce software http://typo.leetsoft.com - Open source weblog engine http://blog.leetsoft.com - Technical weblog
Is there any way to do that sort of thing from a controller? Giving some function a path and then getting the params that path would produce? For example, passing this to some function: "/store/edit/1" and getting back [:controller => "store", :action => "edit", :id => "1"] or whatever the appropriate params for the route are. -- Michael Daines On Apr 4, 2006, at 7:06 AM, Ingo Weiss wrote:> when the "Agile Web Development" book talks about routes, there are > what > looks like console transcripts like the following: > > URL> store > @params = {:controller => ''store'', :action = ''index''} > > Is there something like a console for testing routes (where you could > put in a url and see how rails would route it)??
ruby script/console Loading development environment. app.get >> app.get ''/'' => 200>> app.controller.params=> {"action"=>"index", "controller"=>"shop"} On 4/4/06, Michael Daines <michael.daines@gmail.com> wrote:> > Is there any way to do that sort of thing from a controller? Giving > some function a path and then getting the params that path would > produce? > > For example, passing this to some function: > > "/store/edit/1" > > and getting back > > [:controller => "store", :action => "edit", :id => "1"] > > or whatever the appropriate params for the route are. > > > -- Michael Daines > > > On Apr 4, 2006, at 7:06 AM, Ingo Weiss wrote: > > > when the "Agile Web Development" book talks about routes, there are > > what > > looks like console transcripts like the following: > > > > URL> store > > @params = {:controller => ''store'', :action = ''index''} > > > > Is there something like a console for testing routes (where you could > > put in a url and see how rails would route it)?? > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tobi http://shopify.com - modern e-commerce software http://typo.leetsoft.com - Open source weblog engine http://blog.leetsoft.com - Technical weblog
I''ve seen that, which is good, but I mean from within an action in a controller or elsewhere, not from the console. At some point, my application gets lists of URLs, and I want to know what params their paths produce. (Plus, oops! Those should have been curly braces.) -- Michael Daines On Apr 4, 2006, at 12:00 PM, Tobias L?tke wrote:> ruby script/console > Loading development environment. > app.get >> app.get ''/'' > => 200 >>> app.controller.params > => {"action"=>"index", "controller"=>"shop"} > > > On 4/4/06, Michael Daines <michael.daines@gmail.com> wrote: >> >> Is there any way to do that sort of thing from a controller? Giving >> some function a path and then getting the params that path would >> produce? >> >> For example, passing this to some function: >> >> "/store/edit/1" >> >> and getting back >> >> [:controller => "store", :action => "edit", :id => "1"] >> >> or whatever the appropriate params for the route are.
This is great! Thanks!! Ingo> ruby script/console > Loading development environment. > app.get >> app.get ''/'' > => 200 >>> app.controller.params > => {"action"=>"index", "controller"=>"shop"}-- Posted via http://www.ruby-forum.com/.
Michael Daines wrote:> I''ve seen that, which is good, but I mean from within an action in a > controller or elsewhere, not from the console. > > At some point, my application gets lists of URLs, and I want to know > what params their paths produce.This might help: http://clarkware.com/cgi/blosxom/2006/04/04#HeadlessApp -- Ray