From: Luis Teko Date: 2009-07-12T10:52:45+09:00 Subject: ActiveRecord::AssociationTypeMismatch in MovieController#cre 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' %>

: <%= text_field 'movie', 'title' %>

: <%= text_field 'movie', 'price' %>

: <%= collection_select(:movie,:genre,@genre,:id,:name) %>


<%= 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 -- Posted via http://www.ruby-forum.com/.