undefined method user_id

Basically, Im trying to add comments to photos that other users have uploaded. And Ive encountered an error:

NoMethodError in CommentsController#create undefined method `user_id=' for #<Comment:0x4768cd0>

C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1857:in `method_missing' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1672:in `send' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1672:in `attributes=' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1671:in `each' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1671:in `attributes=' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1505:in `initialize_without_callbacks' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/callbacks.rb:225:in `initialize' #{RAILS_ROOT}/app/controllers/comments_controller.rb:8:in `new' #{RAILS_ROOT}/app/controllers/comments_controller.rb:8:in `create'

This is my comments controller:

class CommentsController < ApplicationController   before_filter :login_required

  def create     @photo = Photo.find_by_user_id_and_id(params[:user_id],                                                             params[:photo_id])

    @comment = Comment.new(:user_id => @logged_in_user.id,                                             :body => params[:comment][:body])     if @photo.comments << @comment       flash[:notice] = 'Comment was successfully created.'       redirect_to photos_path(:user_id => @photo.user,                                         :photo_id => @photo)     else       render :controller => 'photos', :action => 'show',                   :user_id => @photo.user, :photo_id => @photo     end   end

  def destroy     @photo = Photo.find_by_user_id_and_id(@logged_in_user.id,                                                           params[:photo_id],                                                           :include => :user)     @comment = @photo.comments.find(params[:id])     @comment.destroy

    redirect_to entry_path(:user_id => @photo.user.id,                                     :id => @photo.id)   end end

It said that the user_id is undefined when creating a new comment. Any kind soul can tell me how to solve?

It said that the user_id is undefined when creating a new comment. Any kind soul can tell me how to solve?

Do your comments have a user_id column ?

Fred