Forum: Ruby exemple sur le cinéma (rails)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0530f95c50e3eb3177bcba9af4e4de7c?d=identicon&s=25 kungfu-free (Guest)
on 2008-12-13 16:25
(Received via mailing list)
#Movies.rb:
def deleted_roles=(values)
   roles.find(*values).each(&:destroy)
end





#Role.rb:

class Role < ActiveRecord::Base
   belongs_to :movie
   belongs_to :person

   validates_presence_of :movie_id, :person_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 :ok }
74      else
75        format.html { render :action => "edit" }
76        format.xml  { render :xml => @movie.errors, :status
=>:unprocessable_entity }
77      end
78    end
79  end
This topic is locked and can not be replied to.