+ Reply to Thread
Results 1 to 2 of 2

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

  1. #1
    Graham is offline Coder Graham will become famous soon enough
    Join Date
    Feb 2007
    Location
    Dublin
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    Hi all,

    First I'm new to ROR (stated today ) 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
    There are two types of people in this world the closed minded ignorant and the open minded learner. Be the latter

  2. #2
    Graham is offline Coder Graham will become famous soon enough
    Join Date
    Feb 2007
    Location
    Dublin
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

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

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

    not "movies"
    There are two types of people in this world the closed minded ignorant and the open minded learner. Be the latter

+ Reply to Thread

Similar Threads

  1. Ruby On Rails Hosting
    By blacknight in forum Coding Help
    Replies: 8
    Last Post: 21-10-2008, 12:41 AM
  2. Ruby on Rails VS PHP Code Igniter
    By gav240z in forum Coding Help
    Replies: 10
    Last Post: 03-02-2008, 11:04 PM
  3. ASP2.0 or Ruby On Rails?
    By Maksymus007 in forum Webmaster Discussion
    Replies: 6
    Last Post: 15-08-2007, 12:54 AM
  4. Ruby on Rails Developer Needed
    By brightspark in forum Marketplace Requests
    Replies: 2
    Last Post: 03-10-2006, 08:53 AM
  5. Ruby on Rails?
    By blacknight in forum Webmaster Discussion
    Replies: 6
    Last Post: 20-06-2006, 08:00 PM

Visitors found this page by searching for:

No visitors have come to this page from a search engine, yet!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Optimization by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54