Class: RailsPulse::TagsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RailsPulse::TagsController
- Defined in:
- app/controllers/rails_pulse/tags_controller.rb
Constant Summary collapse
- TAG_NAME_REGEX =
Tag validation rules
/\A[a-z0-9_-]+\z/i- MAX_TAG_LENGTH =
50
Instance Method Summary collapse
Methods inherited from ApplicationController
#set_global_filters, #set_time_range
Methods included from PaginationConcern
Instance Method Details
#create ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/rails_pulse/tags_controller.rb', line 9 def create tag = params[:tag] # Validate tag name = validate_tag(tag) if flash[:alert] = elsif @taggable.add_tag(tag) flash[:notice] = "Tag added" else flash[:alert] = "Failed to add tag" end redirect_back(fallback_location: root_path) end |
#destroy ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/rails_pulse/tags_controller.rb', line 25 def destroy tag = params[:tag] if @taggable.remove_tag(tag) flash[:notice] = "Tag removed" else flash[:alert] = "Failed to remove tag" end redirect_back(fallback_location: root_path) end |