Class: PatronMergeListsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/patron_merge_lists_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /patron_merge_lists POST /patron_merge_lists.json



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/patron_merge_lists_controller.rb', line 41

def create
  @patron_merge_list = PatronMergeList.new(params[:patron_merge_list])

  respond_to do |format|
    if @patron_merge_list.save
      flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.patron_merge_list'))
      format.html { redirect_to(@patron_merge_list) }
      format.json { render :json => @patron_merge_list, :status => :created, :location => @patron_merge_list }
    else
      format.html { render :action => "new" }
      format.json { render :json => @patron_merge_list.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /patron_merge_lists/1 DELETE /patron_merge_lists/1.json



85
86
87
88
89
90
91
92
# File 'app/controllers/patron_merge_lists_controller.rb', line 85

def destroy
  @patron_merge_list.destroy

  respond_to do |format|
    format.html { redirect_to(patron_merge_lists_url) }
    format.json { head :no_content }
  end
end

#editObject

GET /patron_merge_lists/1/edit



36
37
# File 'app/controllers/patron_merge_lists_controller.rb', line 36

def edit
end

#indexObject

GET /patron_merge_lists GET /patron_merge_lists.json



6
7
8
9
10
11
12
13
# File 'app/controllers/patron_merge_lists_controller.rb', line 6

def index
  @patron_merge_lists = PatronMergeList.page(params[:page])

  respond_to do |format|
    format.html # index.html.erb
    format.json { render :json => @patron_merge_lists }
  end
end

#newObject

GET /patron_merge_lists/new GET /patron_merge_lists/new.json



26
27
28
29
30
31
32
33
# File 'app/controllers/patron_merge_lists_controller.rb', line 26

def new
  @patron_merge_list = PatronMergeList.new

  respond_to do |format|
    format.html # new.html.erb
    format.json { render :json => @patron_merge_list }
  end
end

#showObject

GET /patron_merge_lists/1 GET /patron_merge_lists/1.json



17
18
19
20
21
22
# File 'app/controllers/patron_merge_lists_controller.rb', line 17

def show
  respond_to do |format|
    format.html # show.html.erb
    format.json { render :json => @patron_merge_list }
  end
end

#updateObject

PUT /patron_merge_lists/1 PUT /patron_merge_lists/1.json



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'app/controllers/patron_merge_lists_controller.rb', line 58

def update
  respond_to do |format|
    if @patron_merge_list.update_attributes(params[:patron_merge_list])
      if params[:mode] == 'merge'
        selected_patron = Patron.where(:id => params[:selected_patron_id]).first
        if selected_patron
          @patron_merge_list.merge_patrons(selected_patron)
          flash[:notice] = t('merge_list.successfully_merged', :model => t('activerecord.models.patron'))
        else
          flash[:notice] = t('merge_list.specify_id', :model => t('activerecord.models.patron'))
          redirect_to patron_merge_list_url(@patron_merge_list)
          return
        end
      else
        flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.patron_merge_list'))
      end
      format.html { redirect_to(@patron_merge_list) }
      format.json { head :no_content }
    else
      format.html { render :action => "edit" }
      format.json { render :json => @patron_merge_list.errors, :status => :unprocessable_entity }
    end
  end
end