Ruby on Rails - link_to with parentheses -


sorry, newbie question.

there lot of questions on "link_to" already, none answer question, don't think specific link_to...

creating link works:

<%= link_to person.automobile_id, person %> 

but, trying does not work:

<%= link_to (translation.request_id, translation) %> 

this produces error:

syntax error, unexpected ',', expecting ')' 

this confuses me, since me looks i'm wrapping parenthesis around arguments link_to.

what misunderstanding?

in cases parentheses method argument optional in ruby.

link_to("link name", path)  

is equivalent

link_to "link name", path 

the latter example more idiomatic in rails community.

however, spacing must preserved. if omit parenthesis there can 1 space between method , argument. may little strange new ruby , rails, used prevalently used quick.

the exception if chaining methods , 1 of earlier methods has argument need include parentheses.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -