Class: OCms::CategoriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- OCms::CategoriesController
- Defined in:
- app/controllers/o_cms/categories_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/o_cms/categories_controller.rb', line 18 def create @category = Category.new(category_params) if @category.save flash[:notice] = "Category was saved successfully." redirect_to edit_category_path(@category) else flash.now[:alert] = "Error creating category. Please try again." render :new end end |
#destroy ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/o_cms/categories_controller.rb', line 47 def destroy @category = Category.find(params[:id]) if @category.destroy flash[:notice] = "\"#{@category.name}\" was deleted successfully." redirect_to action: :index else flash.now[:alert] = "There was an error deleting the category." render :show end end |
#edit ⇒ Object
30 31 32 |
# File 'app/controllers/o_cms/categories_controller.rb', line 30 def edit @category = Category.find(params[:id]) end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/o_cms/categories_controller.rb', line 6 def index @categorys = Category.all end |
#new ⇒ Object
14 15 16 |
# File 'app/controllers/o_cms/categories_controller.rb', line 14 def new @category = Category.new end |
#show ⇒ Object
10 11 12 |
# File 'app/controllers/o_cms/categories_controller.rb', line 10 def show @category = Category.find(params[:id]) end |
#update ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/o_cms/categories_controller.rb', line 34 def update @category = Category.find(params[:id]) @category.assign_attributes(category_params) if @category.save flash[:notice] = "Category was updated successfully." redirect_to edit_category_path(@category) else flash.now[:alert] = "Error saving category. Please try again." render :edit end end |