Emebedded Ruby: Short If Statement -


i'm learning ruby cant embedded ruby work proberly , appreciated.

i'm trying write short version of if statement in embedded ruby

<% entity.attributes.each |key, value| %>   <%= if key == "name"         link_to @entity, edit_entity_path(entity)       else          value       end %> <%= end %> 

according understanding (and post) should able write this

<% entity.attributes.each |key, value| %>   <%= key == "name" ? link_to @entity, edit_entity_path(entity) : value %> <%= end %> 

this doesn't seem work. doing wrong?

ralils error message: syntax error, unexpected tivar, expecting keyword_do or '{' or '(' ...ey == "name") ? ...

thx in advance help

there's link_to_if helper, refactors code this:

<% entity.attributes.each |key, value| %>   <%= link_to_if key == "name", value, edit_entity_path(entity) %> <% end %> 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -