Forum: Ruby on Rails Partial not pulling through values

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
985e151e7f58ccc8908bfa651a8242a7?d=identicon&s=25 Matt Daviss (matt_99)
on 2007-07-26 17:50
Any ideas on this would be grand

I have two models Degree and Qualification and am using a join table
called assigned, in my edit view below I am calling the partial 'form'
at the start and then currently having to call my lines of code to edit
the assigned qualifications in the edit method itself because if I put
it in the partial it doesn't pull through the current values of the
grade text field and the subject dropdown, ideally I want to put it into
the partial as my new view uses the same code

Edit view:

<h1>Editing degree</h1>

<%= error_messages_for :degree %>

<%= start_form_tag :action => 'update', :id => params[:id] %>
<%= render :partial => 'form' %>

<p><label for="assigned_grade">Grade</label><br/>
  <%=text_field 'assigned', 'grade'  %></p>


   <p><label for="assigned_qual_id">Subject</label><br/>
<%=collection_select(:assigned, :qual_id, @quals,:id, :screen_qual,
:prompt => "Select a qualification")%><br />

  <%= submit_tag "Edit" %>
<%= end_form_tag %>

<%= link_to 'Show', :action => 'show', :id => @degree %> |
<%= link_to 'Back', :action => 'list' %>

form partial:

<%= error_messages_for 'degree' %>

  <p><label for="degree_title">Title</label><br/>
<%= text_field 'degree', 'title'  %></p>

<p><label for="degree_detail">Detail</label><br/>
<%= text_area 'degree', 'detail'  %></p>

<p><label for="degree_careers">Careers</label><br/>
<%= text_area 'degree', 'careers'  %></p>

<p><label for="degree_contact">Contact</label><br/>
<%= text_field 'degree', 'contact'  %></p>


<% for interest in Interest.find(:all) %>
  <%= check_box_tag "degree[interest_ids][]",,
@degree.interests.include?(interest) %>
  <%= %>
<% end %>
This topic is locked and can not be replied to.