Class: Admin::BlocksController
- Inherits:
-
AdminController
- Object
- AdminController
- Admin::BlocksController
- Defined in:
- app/controllers/admin/blocks_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/admin/blocks_controller.rb', line 18 def create params[:block][:system_id] = _sid @block = Block.new(params[:block]) @block.user_id = current_user.id if @block.save redirect_to [:admin, @block], :notice => "Successfully created block" else render :action => 'new' end end |
#destroy ⇒ Object
52 53 54 55 56 57 |
# File 'app/controllers/admin/blocks_controller.rb', line 52 def destroy Activity.add(_sid, "Deleted block '#{@block.name}'", current_user.id, "Block") @block = Block.find_sys_id(_sid, params[:id]) @block.destroy redirect_to admin_blocks_url, :notice => "Successfully destroyed block" end |
#edit ⇒ Object
29 30 31 |
# File 'app/controllers/admin/blocks_controller.rb', line 29 def edit @block = Block.find_sys_id(_sid,params[:id]) end |
#index ⇒ Object
4 5 6 7 8 |
# File 'app/controllers/admin/blocks_controller.rb', line 4 def index @blocks = Block.sys(_sid).order(:name) @blocks = @blocks.where('name like "%' + params[:for] + '%" or body like "%' + params[:for] + '%" or description like "%' + params[:for] + '%"') if params[:for].not_blank? @blocks = @blocks.page(params[:page]).per(25) end |
#new ⇒ Object
14 15 16 |
# File 'app/controllers/admin/blocks_controller.rb', line 14 def new @block = Block.new end |
#show ⇒ Object
10 11 12 |
# File 'app/controllers/admin/blocks_controller.rb', line 10 def show @block = Block.find_sys_id(_sid,params[:id]) end |
#update ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/admin/blocks_controller.rb', line 33 def update @block = Block.find_sys_id(_sid,params[:id]) @block.user_id = current_user.id if @block.update_attributes(params[:block]) Activity.add(_sid, "Update block '#{@block.name}'", current_user.id, "Block") if params[:submit_button]=="save-and-edit-again" redirect_to "/admin/blocks/#{@block.id}/edit#editor" else redirect_to "/admin/blocks/#{@block.id}" end return else render :action => 'edit' end end |