Class: LabelsController
- Inherits:
-
FassetsCore::ApplicationController
- Object
- ActionController::Base
- FassetsCore::ApplicationController
- LabelsController
- Defined in:
- app/controllers/labels_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/labels_controller.rb', line 4 def create @label = Label.new(params[:label]) @label.facet_id = params[:facet_id] if @label.save flash[:notice] = "Label was successfully created." redirect_to edit_catalog_facet_path(params[:catalog_id], params[:facet_id]) else if params[:label][:caption].blank? flash[:error] = "Label could not be created! Caption cannot be empty!" else flash[:error] = "Label could not be created!" end redirect_to :back end end |
#destroy ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/labels_controller.rb', line 37 def destroy @label.destroy @facet = @label.facet @catalog = @facet.catalog @label = nil flash[:notice] = "Label removed." respond_to do |format| format.js { } format.html { redirect_to :back } end end |
#sort ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/controllers/labels_controller.rb', line 29 def sort params[:label].each_with_index do |id, position| Label.update(id, :position => position+1) end respond_to do |format| format.js {render :nothing => true} end end |
#update ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/labels_controller.rb', line 19 def update if params[:label][:caption].blank? flash[:error] = "Label could not be updated! Caption cannot be empty!" redirect_to :back return end @label.update_attributes(params[:label]) flash[:notice] = "Label was successfully updated." redirect_to edit_catalog_facet_path(params[:catalog_id], params[:facet_id]) end |