Class: Portfolio::Admin::SiteItemsController
- Inherits:
-
Portfolio::ApplicationController
- Object
- ActionController::Base
- Portfolio::ApplicationController
- Portfolio::Admin::SiteItemsController
- Defined in:
- app/controllers/portfolio/admin/site_items_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/portfolio/admin/site_items_controller.rb', line 21 def create @item = resource.new(item_project_params.merge(site_id: params[:site_id])) if @item.save redirect_to [:edit, :admin, @site, @item], notice: 'Item project was successfully created.' else render :new end end |
#destroy ⇒ Object
53 54 55 56 |
# File 'app/controllers/portfolio/admin/site_items_controller.rb', line 53 def destroy @item.destroy redirect_to [:admin, @site, @resource_name_p], notice: 'Item project was successfully destroyed.' end |
#edit ⇒ Object
17 18 19 |
# File 'app/controllers/portfolio/admin/site_items_controller.rb', line 17 def edit @image = SiteItemImage.new site_item: @item end |
#index ⇒ Object
9 10 11 |
# File 'app/controllers/portfolio/admin/site_items_controller.rb', line 9 def index @items = resource.where(site: @site) end |
#new ⇒ Object
13 14 15 |
# File 'app/controllers/portfolio/admin/site_items_controller.rb', line 13 def new @item = resource.new site: @site end |
#update ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/portfolio/admin/site_items_controller.rb', line 31 def update resp = @item.update(item_project_params) respond_to do |format| format.html { if resp redirect_to [:edit, :admin, @site, @item], notice: 'Item project was successfully updated.' else render :edit end } format.json { if resp render json: @item else render json: { errors: @item.errors. }, status: 400 end } end end |