vendredi 1 mai 2015

Displaying a string and not a integer on an index.html.erb file

After I linked the "program_id" to the accounts table, rails generate migration AddProgramIDToAccounts program_id:interger and adding <td><%= account.program_id %> in the index.hrml.erb file to display the results. However, I'm getting the ID and not the "program name" like in the drop down I created in the _forms.htlm.erb file.

<div class="form-group">
    <%= f.label :program %><br>
    <%= f.collection_select :program_id, Program.all, :id, :program, {prompt: "Choose a Program"}, {class: "btn btn-default dropdown-toggle"} %>
  </div>

I'm feeling that I created the migration incorrectly but I'm not sure.

Rails 4.1.8

ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]

Aucun commentaire:

Enregistrer un commentaire