Hi everyone,
I'm building partial and I need to use a variable inside of another variable name:
I've tried like this:
<div class="form_row"> <label for="<%= field %>"><%= field_title || field.humanize %>:</
<%= form.text_field field, :size => User::field.upcase_SIZE, :maxlength => User::field.upcase_MAX_LENGTH %> </div>
like this:
<div class="form_row"> <label for="<%= field %>"><%= field_title || field.humanize %>:</
<%= form.text_field field, :size => User::#{field.upcase}_SIZE, :maxlength => User::#{field.upcase}_MAX_LENGTH %> </div>
and like this:
<div class="form_row"> <label for="<%= field %>"><%= field_title || field.humanize %>:</
<%= form.text_field field, :size => User::{field.upcase}_SIZE, :maxlength => User::{field.upcase}_MAX_LENGTH %> </div>
To help you understand what I want:
I will call the partial on my view using this code: <% render :partial => "text_field_row", :field => "email", :locals => { :form => form } %>
and what I want to be displayed in this case is:
<div class="form_row"> <label for="email">Email:</label> <%= form.text_field :email, :size => User::EMAIL_SIZE, :maxlength => User::EMAIL_MAX_LENGTH %> </div>
but I will also use it for another fields rather than just email.
In PHP I know I could simply do it by ${all_${name}_text} but how does it work with ruby on rails?
Thanks!