Class: Admin::LookupsController
- Inherits:
-
BaseController
- Object
- BaseController
- Admin::LookupsController
- Defined in:
- app/controllers/admin/lookups_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 |
# File 'app/controllers/admin/lookups_controller.rb', line 18 def create @lookup = Lookup.new(params[:lookup]) if @lookup.save redirect_to admin_lookups_index_path(category: @lookup.category) else render :new end end |
#destroy ⇒ Object
44 45 46 47 48 |
# File 'app/controllers/admin/lookups_controller.rb', line 44 def destroy @lookup = Lookup.find(params[:id]) @lookup.destroy redirect_to admin_lookups_index_path(category: @lookup.category) end |
#edit ⇒ Object
31 32 33 |
# File 'app/controllers/admin/lookups_controller.rb', line 31 def edit @lookup = Lookup.find(params[:id]) end |
#index ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'app/controllers/admin/lookups_controller.rb', line 5 def index @category = params[:category] @lookups = Lookup.where(category: @category).order(:code, :created_at) if @lookups.blank? && @category.present? redirect_to admin_lookups_index_path return end end |
#new ⇒ Object
14 15 16 |
# File 'app/controllers/admin/lookups_controller.rb', line 14 def new @lookup = Lookup.new end |
#show ⇒ Object
27 28 29 |
# File 'app/controllers/admin/lookups_controller.rb', line 27 def show @lookup = Lookup.find(params[:id]) end |
#update ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/controllers/admin/lookups_controller.rb', line 35 def update @lookup = Lookup.find(params[:id]) if @lookup.update_attributes(params[:lookup].permit!) redirect_to admin_lookups_index_path(category: @lookup.category) else render :edit end end |