Guest User

Untitled

a guest
Nov 8th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.46 KB | None | 0 0
  1. class Admin::CategoriesController < ApplicationController
  2.     layout "admin"
  3.    
  4.     def index
  5.         render :template => "admin/categories/index"
  6.     end
  7.     def new
  8.         @category = Category.new
  9.         render :template => "admin/categories/new"
  10.     end
  11.     def create
  12.         @category = Category.new(category_params)
  13.  
  14.         if @category.save
  15.             redirect_to admin_category
  16.         else
  17.             render 'new'
  18.         end
  19.     end
  20.  
  21.     private
  22.     def category_params
  23.         params.require(:category).permit(:title)
  24.     end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment