Tintin81
Tintin81

Reputation: 10207

Passing a symbol to a helper function in Ruby on Rails?

Is there a way to move this part of my form into a helper method?

<%= f.label :address do %>
  <%= f.object.class.human_attribute_name :address %>
  <span>optional</span>
<% end %><br/>

I have a number of occasions where I need the span but I don't know how to pass the :address symbol into a helper function.

Thanks for any help!

Upvotes: 0

Views: 203

Answers (1)

jethroo
jethroo

Reputation: 2124

you might implement this part of view as partial which can be recycled everythere you need it see Layouts and Renderings

You can pass variables towards Partials as described in 3.4.4 Passing Local Variables

Upvotes: 1

Related Questions