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:
In context of Rails routes:
There is no difference.
No, it's the same.
Just a more readable, 'from' => 'to'
and 'from', to: 'to'
Yes.
The =>
notation it's a hash ruby feature, and related to the :symbol
.
You can write symbols by two ways :key => value
and key: value
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With