ruby on rails - Difference in ways to call partials? -


i assuming applies other things well, i've noticed in tutorials i've gone through far. basically, difference between:

<%= render :partial => "shared/warning" %> 

and

<%= render partial: "shared/warning" %> 

the syntax hash literal in ruby is:

{ key => value } 

the key can object, including symbol, eg.

{ :foo => "bar" } 

using symbol keys in hash became popular, , idiomatic in ruby in ruby 1.9 optional syntax added hash created symbol keys, , there on following precisely equivalent above:

{ foo: "bar" } 

update

further specific use case, ruby allows drop {}s when passing hash argument method (as being able drop ()s), following equivalent:

foobar( { foo: "bar" } ) foobar( foo: "bar" ) foobar foo: "bar" foobar :foo => "bar" 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -