Class: MergesController
- Inherits:
-
ArtfullyOseController
- Object
- ActionController::Base
- ArtfullyOseController
- MergesController
- Defined in:
- app/controllers/merges_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/merges_controller.rb', line 17 def create @winner = Person.find(params[:winner]) @loser = Person.find(params[:loser]) if @winner.type == @loser.type @result = Person.merge(@winner, @loser) flash[:notice] = "#{@loser} has been merged into this record" redirect_to person_path(:id => @winner.id) else flash[:error] = "Both records must be the same time. A company cannot merge with an individual." redirect_to new_merge_path(:loser => @person) end end |
#new ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/merges_controller.rb', line 2 def new @loser = Person.find(params[:loser]) without_winner do if is_search(params) @people = Person.search_index(params[:search].dup, current_user.current_organization) else @people = Person.recent(current_user.current_organization) end @people = @people.reject { |person| person.id == @loser.id } @people = @people.reject { |person| person.type != @loser.type } @people = @people.paginate(:page => params[:page], :per_page => 20) render :find_person end end |