Sha256: 8f629b0702c36c0f546a8c254b3417312e9d2222f07941663638381c46255dd3
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
class DownloadsController < ApplicationController before_filter :authenticate before_filter :authenticate_with_admin def index @downloads = Download.by_recent.paginate(:page => params[:page], :per_page => 50) switch_to_admin_layout end def new @download = Download.new switch_to_admin_layout end def edit @download = Download.find(params[:id]) switch_to_admin_layout end def create @download = Download.new(download_params) if @download.save redirect_to downloads_path, notice: 'Your asset has been saved.' else render action: "new", layout: 'admin' end end def update @download = Download.find(params[:id]) if @download.update_attributes(download_params) redirect_to downloads_path, notice: 'Your asset has been saved.' else render action: "edit", layout: 'admin' end end def destroy @download = Download.find(params[:id]) @download.destroy redirect_to downloads_url end private # Never trust parameters from the scary internet, only allow the white list through. def download_params params.require(:download).permit(:name, :thing) end end
Version data entries
3 entries across 3 versions & 1 rubygems