Class: Admin::HelpController
- Inherits:
-
AdminController
- Object
- AdminController
- Admin::HelpController
- Defined in:
- app/controllers/admin/help_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #delete_image ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #images ⇒ Object
- #index ⇒ Object
- #update ⇒ Object
- #upload ⇒ Object
Instance Method Details
#create ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'app/controllers/admin/help_controller.rb', line 56 def create help = Help.new help.name = params[:help][:name] help.path = help.name.urlise help.save redirect_to "/admin/help/#{help.id}/edit" end |
#delete_image ⇒ Object
13 14 15 16 17 |
# File 'app/controllers/admin/help_controller.rb', line 13 def delete_image HelpImage.delete(params[:id]) redirect_to "/admin/help/images" end |
#destroy ⇒ Object
51 52 53 54 |
# File 'app/controllers/admin/help_controller.rb', line 51 def destroy Help.delete(params[:id]) redirect_to "/admin/helps" end |
#edit ⇒ Object
4 5 6 |
# File 'app/controllers/admin/help_controller.rb', line 4 def edit @help = Help.find(params[:id]) end |
#images ⇒ Object
8 9 10 11 |
# File 'app/controllers/admin/help_controller.rb', line 8 def images @images = HelpImage.order(:updated_at).page(params[:page]).per(20) end |
#index ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/admin/help_controller.rb', line 36 def index if params[:search] search_for = params[:search] search = Tire.search "#{index_name}_helps" do query do string search_for, :fields=>["name", "body", "path"] end end @helps = search.results else @helps = Help.order(:name).all end end |
#update ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/admin/help_controller.rb', line 25 def update @help = Help.find(params[:id]) if @help.update_attributes(params[:help]) redirect_to "/db/help/#{@help.path}" return else render "edit" end end |
#upload ⇒ Object
19 20 21 22 23 |
# File 'app/controllers/admin/help_controller.rb', line 19 def upload image = HelpImage.new(params[:help_image]) image.save redirect_to "/admin/help/images" end |