ActiveRecord::AssociationTypeMismatch in MovieController#cre

L

Luis Teko

Great Gurus again ill be needing ur help having n error

ActiveRecord::AssociationTypeMismatch in MovieController#create
Genre expected, got String

<h1>Add new movie</h1>
<%= form_tag :action => 'create' %>
<p><label for="movie_title">Title</label>:
<%= text_field 'movie', 'title' %></p>
<p><label for="movie_price">Price</label>:
<%= text_field 'movie', 'price' %></p>
<p><label for="movie_genre">Genre</label>:
<%= collection_select:)movie,:genre,@genre,:id,:name) %></p>
<p><label for="movie_description">Description</label><br/>
<%= text_area 'movie', 'description' %></p>
<%= submit_tag "Create" %>

class MovieController < ApplicationController
def list
@movies = Movie.find:)all)
end

def show
@movie = Movie.find(params[:id])
end

def new
@movie = Movie.new
@genres = Genre.find:)all)
end

def create
@movie = Movie.new(params[:movie])
if @movie.save
redirect_to :action => 'list'
else
@genres = Genre.find:)all)
render :action => 'new'
end
end

def edit
@movie = Movie.find(params[:id])
@genres = Genre.find:)all)
end

def update
@movie = Movie.find(params[:id])
if @movie.update_attributes(params[:movie])
redirect_to :action => 'show', :id => @movie
else
@genres = Genre.find:)all)
render :action => 'edit'
end
end

def delete
Movie.find(params[:id]).destroy
redirect_to :action => 'list'
end

def show_genres
@genres = Genre.find(params[:id])
end
end


class Movie < ActiveRecord::Base
belongs_to :genre
validates_presence_of :title
validates_numericality_of :price, :message=>"Error Message"
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top