Class: Krikri::HarvestSourcesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Krikri::HarvestSourcesController
- Defined in:
- app/controllers/krikri/harvest_sources_controller.rb
Overview
Marshalls HarvestSources for views
Constant Summary collapse
- BadRequestError =
Class.new(RuntimeError)
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/krikri/harvest_sources_controller.rb', line 39 def create ok_params = harvest_source_params ok_params[:institution_id] = params[:institution_id] @harvest_source = HarvestSource.new(ok_params) if @harvest_source.save institution = Institution.find(params[:institution_id]) redirect_to institution_path(institution) else render 'new' end end |
#destroy ⇒ Object
51 52 53 54 55 56 |
# File 'app/controllers/krikri/harvest_sources_controller.rb', line 51 def destroy @harvest_source = HarvestSource.find(params[:id]) institution = @harvest_source.institution @harvest_source.destroy! redirect_to institution_harvest_sources_path(institution) end |
#edit ⇒ Object
22 23 24 |
# File 'app/controllers/krikri/harvest_sources_controller.rb', line 22 def edit @harvest_source = HarvestSource.find(params[:id]) end |
#index ⇒ Object
7 8 9 10 11 |
# File 'app/controllers/krikri/harvest_sources_controller.rb', line 7 def index @harvest_sources = HarvestSource.where(institution_id: params[:institution_id]) @institution = Institution.find(params[:institution_id]) end |
#new ⇒ Object
17 18 19 20 |
# File 'app/controllers/krikri/harvest_sources_controller.rb', line 17 def new @harvest_source = HarvestSource .new(institution_id: params[:institution_id]) end |
#show ⇒ Object
13 14 15 |
# File 'app/controllers/krikri/harvest_sources_controller.rb', line 13 def show @harvest_source = HarvestSource.find(params[:id]) end |
#update ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/krikri/harvest_sources_controller.rb', line 26 def update @harvest_source = HarvestSource.find(params[:id]) begin if @harvest_source.update(harvest_source_params) redirect_to @harvest_source else render 'edit' end rescue BadRequestError render nothing: true, status: :bad_request end end |