class <%= controller_class_name %>Controller < ApplicationController def index end def create begin @<%= singular_name %> = <%= class_name %>.new( params[:<%= singular_name %>].merge( :<%= first_id_column %> => params[:<%= first_id_column %>], :<%= second_id_column %> => params[:<%= second_id_column %>] )) @successful = @<%= singular_name %>.save rescue flash[:error], @successful = $!.to_s, false end respond_to do |type| type.html {return redirect_to_main} end end def update begin @<%= singular_name %> = <%= class_name %>.find(params[:id]) @successful = @<%= singular_name %>.update_attributes(params[:<%= singular_name %>]) rescue flash[:error], @successful = $!.to_s, false end respond_to do |type| type.html {return redirect_to_main} end end def destroy begin @successful = <%= class_name %>.find(params[:id]).destroy rescue flash[:error], @successful = $!.to_s, false end respond_to do |type| type.html {return redirect_to_main} end end protected def redirect_to_main redirect_to common_redirection end def common_redirection { :action => 'index' } end end