diff options
Diffstat (limited to 'app/controllers/assets_controller.rb')
| -rw-r--r-- | app/controllers/assets_controller.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index cfaf176..d150e06 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb | |||
| @@ -2,15 +2,14 @@ class AssetsController < ApplicationController | |||
| 2 | 2 | ||
| 3 | # Private | 3 | # Private |
| 4 | 4 | ||
| 5 | before_filter :login_required | 5 | before_action :login_required |
| 6 | 6 | ||
| 7 | layout 'admin' | 7 | layout 'admin' |
| 8 | 8 | ||
| 9 | def index | 9 | def index |
| 10 | @assets = Asset.all.paginate( | 10 | @assets = Asset.order('id DESC').paginate( |
| 11 | :page => params[:page], | 11 | :page => params[:page], |
| 12 | :per_page => 20, | 12 | :per_page => 20 |
| 13 | :order => 'id DESC' | ||
| 14 | ) | 13 | ) |
| 15 | end | 14 | end |
| 16 | 15 | ||
| @@ -44,7 +43,7 @@ class AssetsController < ApplicationController | |||
| 44 | # POST /assets | 43 | # POST /assets |
| 45 | # POST /assets.xml | 44 | # POST /assets.xml |
| 46 | def create | 45 | def create |
| 47 | @asset = Asset.new(params[:asset]) | 46 | @asset = Asset.new(asset_params) |
| 48 | 47 | ||
| 49 | respond_to do |format| | 48 | respond_to do |format| |
| 50 | if @asset.save | 49 | if @asset.save |
| @@ -64,7 +63,7 @@ class AssetsController < ApplicationController | |||
| 64 | @asset = Asset.find(params[:id]) | 63 | @asset = Asset.find(params[:id]) |
| 65 | 64 | ||
| 66 | respond_to do |format| | 65 | respond_to do |format| |
| 67 | if @asset.update_attributes(params[:asset]) | 66 | if @asset.update(asset_params) |
| 68 | flash[:notice] = 'Asset was successfully updated.' | 67 | flash[:notice] = 'Asset was successfully updated.' |
| 69 | format.html { redirect_to(@asset) } | 68 | format.html { redirect_to(@asset) } |
| 70 | format.xml { head :ok } | 69 | format.xml { head :ok } |
| @@ -86,4 +85,10 @@ class AssetsController < ApplicationController | |||
| 86 | format.xml { head :ok } | 85 | format.xml { head :ok } |
| 87 | end | 86 | end |
| 88 | end | 87 | end |
| 88 | |||
| 89 | private | ||
| 90 | |||
| 91 | def asset_params | ||
| 92 | params.require(:asset).permit(:name, :upload) | ||
| 93 | end | ||
| 89 | end | 94 | end |
