Class: SeriesStatementsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- SeriesStatementsController
- Defined in:
- app/controllers/series_statements_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /series_statements POST /series_statements.json.
-
#destroy ⇒ Object
DELETE /series_statements/1 DELETE /series_statements/1.json.
-
#edit ⇒ Object
GET /series_statements/1/edit.
-
#index ⇒ Object
GET /series_statements GET /series_statements.json.
-
#new ⇒ Object
GET /series_statements/new GET /series_statements/new.json.
-
#show ⇒ Object
GET /series_statements/1 GET /series_statements/1.json.
-
#update ⇒ Object
PUT /series_statements/1 PUT /series_statements/1.json.
Instance Method Details
#create ⇒ Object
POST /series_statements POST /series_statements.json
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/controllers/series_statements_controller.rb', line 69 def create @series_statement = SeriesStatement.new(series_statement_params) manifestation = Manifestation.find(@series_statement.manifestation_id) rescue nil respond_to do |format| if @series_statement.save @series_statement.manifestations << manifestation if manifestation format.html { redirect_to @series_statement, notice: t('controller.successfully_created', model: t('activerecord.models.series_statement')) } format.json { render json: @series_statement, status: :created, location: @series_statement } else @frequencies = Frequency.all format.html { render action: "new" } format.json { render json: @series_statement.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /series_statements/1 DELETE /series_statements/1.json
108 109 110 111 112 113 114 115 |
# File 'app/controllers/series_statements_controller.rb', line 108 def destroy @series_statement.destroy respond_to do |format| format.html { redirect_to series_statements_url } format.json { head :no_content } end end |
#edit ⇒ Object
GET /series_statements/1/edit
64 65 |
# File 'app/controllers/series_statements_controller.rb', line 64 def edit end |
#index ⇒ Object
GET /series_statements GET /series_statements.json
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/series_statements_controller.rb', line 9 def index search = Sunspot.new_search(SeriesStatement) query = params[:query].to_s.strip page = params[:page] || 1 if query.present? @query = query.dup query = query.gsub(' ', ' ') end search.build do fulltext query if query.present? paginate page: page.to_i, per_page: SeriesStatement.default_per_page order_by :position, :asc end #work = @work manifestation = @manifestation series_statement_merge_list = @series_statement_merge_list search.build do with(:manifestation_id).equal_to manifestation.id if manifestation with(:series_statement_merge_list_ids).equal_to series_statement_merge_list.id if series_statement_merge_list end page = params[:page] || 1 search.query.paginate(page.to_i, SeriesStatement.default_per_page) search_result = search.execute! @series_statements = search_result.results respond_to do |format| format.html # index.html.erb format.json { render json: @series_statements } end end |
#new ⇒ Object
GET /series_statements/new GET /series_statements/new.json
54 55 56 57 58 59 60 61 |
# File 'app/controllers/series_statements_controller.rb', line 54 def new @series_statement = SeriesStatement.new respond_to do |format| format.html # new.html.erb format.json { render json: @series_statement } end end |
#show ⇒ Object
GET /series_statements/1 GET /series_statements/1.json
43 44 45 46 47 48 49 50 |
# File 'app/controllers/series_statements_controller.rb', line 43 def show respond_to do |format| format.html # show.html.erb format.json { render json: @series_statement } #format.js #format.mobile end end |
#update ⇒ Object
PUT /series_statements/1 PUT /series_statements/1.json
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/controllers/series_statements_controller.rb', line 88 def update if params[:move] move_position(@series_statement, params[:move]) return end respond_to do |format| if @series_statement.update(series_statement_params) format.html { redirect_to @series_statement, notice: t('controller.successfully_updated', model: t('activerecord.models.series_statement')) } format.json { head :no_content } else @frequencies = Frequency.all format.html { render action: "edit" } format.json { render json: @series_statement.errors, status: :unprocessable_entity } end end end |