Class: Gluttonberg::Public::FlagController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Gluttonberg::Public::FlagController
- Defined in:
- app/controllers/gluttonberg/public/flag_controller.rb
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/gluttonberg/public/flag_controller.rb', line 16 def create flag = current_user.flags.create params[:flag] flash[:notice] = if flag.new_record? "You already flagged this content!" else # success "Content has been flagged!" end respond_to do |format|# note: you'll need to ensure that this route exists format.html { url = "" begin if flag.flaggable.respond_to?(:commentable) url = polymorphic_path(flag.flaggable.commentable) else url = polymorphic_path(flag.flaggable) end flag.update_attributes(:url => url) redirect_to url rescue => e end } # format.js # render some js trickery end end |
#new ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'app/controllers/gluttonberg/public/flag_controller.rb', line 5 def new model = nil if params[:flaggable_type].include?("Gluttonberg::") model = Gluttonberg.const_get(params[:flaggable_type][13..-1]) else model = Kernel.const_get(params[:flaggable_type]) end @flaggable = model.find(params[:flaggable_id]) end |