NoMethodError Comments Controller - Rails 3.2 -
i have 2 models comments , programmes. , error.
my comments_conroller.rb looks
def create @programmme = programme.find(params[:programme_id]) @comment = @programme.comments.create!(params[:comment]) if @comment.save redirect_to @comment.programme, notice: "comment has been sent." else format.html { redirect_to @comment.programme, notice: "there error creating comment."} end end
i have tried using build instead of create.
def create @programmme = programme.find(params[:programme_id]) @comment = @programme.comments.build(params[:comment]) if @comment.save redirect_to @comment.programme, notice: "comment has been sent." else format.html { redirect_to @comment.programme, notice: "there error creating comment."} end end
programme.rb
class programme < activerecord::base attr_accessible :biography, :broadcasttime, :description, :title # associations has_many :comments, :dependent => :destroy end
comment.rb
class comment < activerecord::base attr_accessible :email, :location, :message, :name, :requestfor, :song #associations belongs_to :programme end
and routes.rb looks this
digneradio::application.routes.draw resources :programmes resources :comments end resources :replays resources :articles end
not sure i'm going wrong appreciate help.
there error in spelling of programme, first utilize @programmme(with 3m) , in next step utilize @programme.
ruby-on-rails-3.2 nomethoderror
No comments:
Post a Comment