Class: Backend::AssetsController
Instance Method Summary
collapse
#page_number, #paginate, #per_page
#breadcrumb, #current_admin, #default_app_locale, #translate_notice
#crypt
Instance Method Details
#create ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/backend/assets_controller.rb', line 24
def create
@model = Asset.new allowed_params
if @model.save
redirect_to backend_assets_path, notice: translate_notice(:added, :file)
else
render :new
end
end
|
#destroy ⇒ Object
42
43
44
45
|
# File 'app/controllers/backend/assets_controller.rb', line 42
def destroy
@model.destroy if @model.deletable?
redirect_to backend_assets_path, notice: translate_notice(:deleted, :file)
end
|
#index ⇒ Object
7
8
9
10
|
# File 'app/controllers/backend/assets_controller.rb', line 7
def index
@search = Asset.ransack params[:q]
@assets = @search.result(distinct: true).order('id DESC').page(page_number).per_page(per_page)
end
|
#new ⇒ Object
20
21
22
|
# File 'app/controllers/backend/assets_controller.rb', line 20
def new
@model = Asset.new
end
|
#show ⇒ Object
12
13
14
15
16
17
18
|
# File 'app/controllers/backend/assets_controller.rb', line 12
def show
send_data(
File.open(@model.filename.path).read,
filename: @model.actual_filename,
type: @model.content_type
)
end
|
#update ⇒ Object
34
35
36
37
38
39
40
|
# File 'app/controllers/backend/assets_controller.rb', line 34
def update
if @model.update_attributes allowed_params
redirect_to backend_assets_path, notice: translate_notice(:edited, :file)
else
render :edit
end
end
|