K
kungfu-free
#Movies.rb:
def deleted_roles=(values)
roles.find(*values).each(&:destroy)
end
#Role.rb:
class Role < ActiveRecord::Base
belongs_to :movie
belongs_to erson
validates_presence_of :movie_id, erson_id, :name
def to_s
[person.full_name, name].join(' - ')
end
end
movies_controller.rb:
65 def update
66 @movie = Movie.find(params[:id])
67 debugger
68
69 respond_to do |format|
70 if @movie.update_attributes(params[:movie])
71 flash[:notice] = 'Movie was successfully updated.'
72 format.html { redirect_to(@movie) }
73 format.xml { head k }
74 else
75 format.html { render :action => "edit" }
76 format.xml { render :xml => @movie.errors, :status
=>:unprocessable_entity }
77 end
78 end
79 end
def deleted_roles=(values)
roles.find(*values).each(&:destroy)
end
#Role.rb:
class Role < ActiveRecord::Base
belongs_to :movie
belongs_to erson
validates_presence_of :movie_id, erson_id, :name
def to_s
[person.full_name, name].join(' - ')
end
end
movies_controller.rb:
65 def update
66 @movie = Movie.find(params[:id])
67 debugger
68
69 respond_to do |format|
70 if @movie.update_attributes(params[:movie])
71 flash[:notice] = 'Movie was successfully updated.'
72 format.html { redirect_to(@movie) }
73 format.xml { head k }
74 else
75 format.html { render :action => "edit" }
76 format.xml { render :xml => @movie.errors, :status
=>:unprocessable_entity }
77 end
78 end
79 end