# ActiveRecord::AssociationTypeMismatch in MovieController#cre

**URL:** <https://www.ruby-forum.com/t/activerecord-associationtypemismatch-in-moviecontroller-cre/171947>\
**Category:** Ruby\
**Created:** [July 12, 2009, 3:52am UTC](https://www.ruby-forum.com/t/activerecord-associationtypemismatch-in-moviecontroller-cre/171947 "2009-07-12T03:52:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ouikoto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/e68b1a/32.png) [@ouikoto](https://www.ruby-forum.com/u/ouikoto)\
**Post date:** [July 12, 2009, 3:52am UTC](https://www.ruby-forum.com/t/activerecord-associationtypemismatch-in-moviecontroller-cre/171947/1 "2009-07-12T03:52:43Z")

</div>

Great Gurus again ill be needing ur help having n error

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

> > > > here’s the view;

# Add new movie
\<%= form\_tag :action =\> 'create' %\>

Title: \<%= text\_field 'movie', 'title' %\>

Price: \<%= text\_field 'movie', 'price' %\>

Genre: \<%= collection\_select(:movie,:genre,@genre,:id,:name) %\>

Description  
\<%= text\_area 'movie', 'description' %\>

\<%= submit\_tag "Create" %\> \<%= link\_to 'Back', {:action =\> 'list'} %\>

> > > > controller:

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

> > > here’s the model

class Movie \< ActiveRecord::Base  
belongs\_to :genre  
validates\_presence\_of :title  
validates\_numericality\_of :price, :message=\>“Error Message”  
end
