Hi,
when the “Agile Web D.” 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
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 W. [email protected] wrote:
Ingo
–
Posted via http://www.ruby-forum.com/.
Rails mailing list
[email protected]
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 D.
ruby script/console
Loading development environment.
app.get >> app.get ‘/’
=> 200
app.controller.params
=> {“action”=>“index”, “controller”=>“shop”}
On 4/4/06, Michael D. [email protected] wrote:
when the “Agile Web D.” book talks about routes, there are
Rails mailing list
[email protected]
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 D.
On Apr 4, 2006, at 12:00 PM, Tobias Lütke wrote:
Michael D. 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