Class: Carload::DashboardController
Instance Method Summary
collapse
#associated_model_name, #id_or_ids, #image?, #needs_upload?, #polymorphic?
Instance Method Details
#create ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/carload/dashboard_controller.rb', line 42
def create
authorize :carload_dashboard, :create? unless Carload.auth_solution == :none
@object = @model_class.create model_params
if @object.save
redirect_to action: :index, model: @model_names
else
render :new
end
end
|
#destroy ⇒ Object
61
62
63
64
65
|
# File 'app/controllers/carload/dashboard_controller.rb', line 61
def destroy
authorize :carload_dashboard, :destroy? unless Carload.auth_solution == :none
@object.destroy
redirect_to action: :index, model: @model_names
end
|
#edit ⇒ Object
38
39
40
|
# File 'app/controllers/carload/dashboard_controller.rb', line 38
def edit
authorize :carload_dashboard, :edit? unless Carload.auth_solution == :none
end
|
#index ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/carload/dashboard_controller.rb', line 16
def index
authorize :carload_dashboard, :index? unless Carload.auth_solution == :none
if params[:search].present?
@query = params[:search][:query]
case Carload.search_engine
when :elasticsearch
@objects = @model_class.search(params[:search][:query]).records.page(params[:page])
when :pg_search
@objects = @model_class.search(params[:search][:query]).page(params[:page])
end
else
@objects = @model_class.page(params[:page])
end
@show_attributes = Dashboard.model(@model_name).index_page[:shows][:attributes] + [:created_at, :updated_at]
render "dashboard/#{@model_names}/index.html.erb"
end
|
#new ⇒ Object
33
34
35
36
|
# File 'app/controllers/carload/dashboard_controller.rb', line 33
def new
authorize :carload_dashboard, :new? unless Carload.auth_solution == :none
@object = @model_class.new
end
|
#search ⇒ Object
67
68
69
70
|
# File 'app/controllers/carload/dashboard_controller.rb', line 67
def search
params[:action] = :index
index
end
|
#show_config ⇒ Object
72
73
|
# File 'app/controllers/carload/dashboard_controller.rb', line 72
def show_config
end
|
#update ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'app/controllers/carload/dashboard_controller.rb', line 52
def update
authorize :carload_dashboard, :update? unless Carload.auth_solution == :none
if @object.update model_params
redirect_to action: :index, model: @model_names
else
render :edit
end
end
|