Help needed with linking tables and saving records in ruby on rails

Status
Not open for further replies.

Graham

New Member
Hi all,

First I'm new to ROR (stated today :D) and I've googled abit to see if I could sort this out but I'm drawing a blank.

I'm using bitnami rubystack and netbeans 6.8, I have two tables movies and durations which I used netbeans to create the scaffolds for. I then edited the movies table to include a foreign key reference to the durations table and edit both models to include has_many and belongs_to

The problem seems to be with the code below (the new.html.erb) as it will not save the selected duration as I can't figure out where to include the :runningtime attribute.

Code:
<h1>New movie</h1>
<% form_for(@movie) do |f| %>
  <%= f.error_messages %>
  <p>
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </p>
  <p>
    <%= f.label :info %><br />
    <%= f.text_area :info %>
  </p>
  <p> <label for="Movie_runningtime">Please select the running time</label><br/>
<%= select("movies","runningtime", Duration.find(:all, :order=>"showlength DESC").collect {|d| [d.showlength, d.id]})%>
  </p>
 
  <p>
    <%= f.submit 'Create' %>
  </p>
<% end %>
<%= link_to 'Back', movies_path %>

All help appricated,

Graham
 

Graham

New Member
I've sorted the above issue, the parameters for the select should have read

<%=select("movie","runningtime"................

not "movies"
 
Status
Not open for further replies.
Award-winning Mac antivirus and Internet security software
Top