I have two models, Review and Album.

Album has many reviews, and Review belongs to Album as seen below in
their respective model files.

class Review < ActiveRecord::Base
        belongs_to :album
end

class Album < ActiveRecord::Base
        has_many :reviews
end

I then added a form to submit reviews for an album:

<% form_for @review do |f| %>
        <textarea cols="40" id="review_productReview"
name="review[productReview]" rows="10"></textarea><br>

        <input type='hidden' id="review_product" name="review[product]"
value='<%= @album.title%>' >
        <input type='hidden' id="review_productCreator"
name="review[productCreator]" value='<%= @album.artist%>' >
        <input name="commit" type="submit" value="Submit Review" />
<% end %>

In my controller I have :

class ReviewsController < ApplicationController

  def create
        @review=Review.new(params[:review])
        @[EMAIL PROTECTED]
        @review.save
        redirect_to '/inventory'
  end

end

i'm not sure that @[EMAIL PROTECTED] is the correct syntax, but even
at the command line when I instantiate an object of type Review and do
Review.album.title="GoldDigger", it says that album is an undefined
method.  The only thing I can think of is that I am missing something
when I set up the associations.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to