Reputation: 14058
I ran across some routes that followed this format:
resources :foobar, except: "create"
I was just wondering how it worked to have "except:" instead of the symbol ":except" as I see in most documentation.
What is actually happening in this case? Is it calling a method called "except"? What does the colon do?
Upvotes: 0
Views: 147
Reputation: 434835
Ruby 1.9 supports a JavaScript-ish Hash syntax so this:
resources :foobar, except: 'create'
is the same as this:
resources :foobar, :except => 'create'
The new syntax has limitations though:
:'this.that'
.:$set
(which appear all over the place if you're using MongoDB).I'm not sure what the exact restrictions are as I don't use it (I do a fair bit of MongoDB work and I have a thing for consistency) but I think the symbols need to match /^[a-z_]\w*/i
(or technically, anything that can be used as a label) to be used with the new format.
Upvotes: 2