Class: Admin::LookupsController
Instance Method Summary
collapse
#policy
#sortable_columns
#add_success_msg, #apply, #build_resource, #load_resource!, #per_page, #redirect_after_save, #redirect_or_render, #resource, #resource_model, #resource_name, #resource_params, #resources
#back_uri, #last_uri, #no_cache!, #redirect_to_back, #redirect_to_last, #store_path_history
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
|