RubyFlow The Ruby and Rails community linklog


The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Mapping URLs in Rails

I just blogged about mapping urls in Rails explaining how to create restful routes when you want route names to be different from model names.


I would not put :url=> "/add" hard-coded like that. It will break if you deploy your rails app at a suburi, it also is another place you need to change if you decide to change your routes from /add to something else (say, you want to internationalize it so it uses the spanish word for ‘add’ in the url or something).

The Rails way to do this is with a routing method alias, or a hash, describing what you want to do, and let the rails routing translate that to a URL – if the routing changes, your view doesn’t have to.

 :url => {:controller => 'book_reviews', :action => "create"}


 :url => book_review_create_path()

This outlet sells various high end rolex replica. Among our replicas, the Rolex Daytona watches are hot. The Rolex Daytona rolex replica uk is one of the most iconic watches at this online store. This rolex replica watches is scratch free. It looks bright and rich. The unique style is accentuated by great expertise.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in