class EditorsController

Public Instance Methods

create() click to toggle source
# File app/controllers/editors_controller.rb, line 8
def create
  @editor = Person.find(params[:editor_id])
  
  unless @person.editors.include?(@editor)
    @person.editors << @editor
  end
  
  flash[:notice] = "#{@editor.name} can now edit #{@person.name}'s account"
  
  if params[:return_to] == "admin"
    redirect_to edit_admin_person_path(@person)
  else
    redirect_to edit_person_path(@person)
  end
end
destroy() click to toggle source
# File app/controllers/editors_controller.rb, line 24
def destroy
  @editor = Person.find(params[:editor_id])
  
  if @person.editors.include?(@editor)
    @person.editors.delete @editor
  end
  
  flash[:notice] = "#{@editor.name} can no longer edit #{@person.name}'s account"
  
  if params[:return_to] == "admin"
    redirect_to edit_admin_person_path(@person)
  else
    redirect_to edit_person_path(@person)
  end
end