I have been noticing that the rails community has been moving towards using the ":" notation for more things. And now recently I received a comment in a code review that this:
post 'examples/', to: 'examples#index'
was better than this:
post "examples/" => "examples#index"
My questions are:
- Is there a difference between these two statements?
- If so why is one better than the other?
- Why is the rails community switching to the ":" notation (or are they)?
- Moving forward with rails 4 and soon 5, are both formats still acceptable?
post "examples/" :to => "examples#index"
Thepost
method accepts a number of definitions, including a simple hash. – Brandiebrandise