Hi,
I’m new at this… can you please help me…
the drop down menus are fine, however when i click submit the
selection is not saved and it tells me that movie and type can’t be
blank
Here is my movie_types controller
class MovieTypesController < ApplicationController
before_filter :login_required, :only => [:new, :create]
GET /movie_types
GET /movie_types.xml
def index
@movie_types = MovieType.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @movie_types }
end
end
GET /movie_types/1
GET /movie_types/1.xml
def show
@movie_type = MovieType.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @movie_type }
end
end
GET /movie_types/new
GET /movie_types/new.xml
def new
@movie_type = MovieType.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @movie_type }
end
end
GET /movie_types/1/edit
def edit
@movie_type = MovieType.find(params[:id])
end
POST /movie_types
POST /movie_types.xml
def create
@movie_type = MovieType.new(params[:movie_type])
respond_to do |format|
if @movie_type.save
flash[:notice] = 'MovieType was successfully created.'
format.html { redirect_to(@movie_type) }
format.xml { render :xml => @movie_type, :status
=> :created, :location => @movie_type }
else
format.html { render :action => “new” }
format.xml { render :xml => @movie_type.errors, :status
=> :unprocessable_entity }
end
end
end
PUT /movie_types/1
PUT /movie_types/1.xml
def update
@movie_type = MovieType.find(params[:id])
respond_to do |format|
if @movie_type.update_attributes(params[:movie_type])
flash[:notice] = 'MovieType was successfully updated.'
format.html { redirect_to(@movie_type) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @movie_type.errors, :status
=> :unprocessable_entity }
end
end
end
DELETE /movie_types/1
DELETE /movie_types/1.xml
def destroy
@movie_type = MovieType.find(params[:id])
@movie_type.destroy
respond_to do |format|
format.html { redirect_to(movie_types_url) }
format.xml { head :ok }
end
end
end
view: new.html
New movie_type
<%= error_messages_for :movie_type %>
<% form_for(@movie_type) do |f| %>
Type
<%= collection_select(:type, :type_id, Type.find(:all), :id, :name)%>
Movie
<%= collection_select(:movie, :movie_id, Movie.find
(:all), :id, :title) %>
<%= f.submit "Create" %>
<% end %><%= link_to ‘Back’, movie_types_path %>
thank you