Class: Flyboy::GoalsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Flyboy::GoalsController
- Defined in:
- app/controllers/flyboy/goals_controller.rb
Instance Method Summary collapse
- #close ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #open ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#close ⇒ Object
91 92 93 94 95 96 97 98 99 |
# File 'app/controllers/flyboy/goals_controller.rb', line 91 def close if @goal.close! flash[:success] = t("messages.goals.close_ok") else flash[:danger] = t("messages.goals.close_error") end redirect_to goals_path end |
#create ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/flyboy/goals_controller.rb', line 41 def create @goal ||= Goal.new(goal_params) :create, @goal if @goal.save flash[:success] = t("messages.goals.create_ok") redirect_to @goal else render :new end end |
#destroy ⇒ Object
74 75 76 77 78 79 |
# File 'app/controllers/flyboy/goals_controller.rb', line 74 def destroy :delete, @goal @goal.destroy redirect_to goals_path end |
#edit ⇒ Object
54 55 56 |
# File 'app/controllers/flyboy/goals_controller.rb', line 54 def edit :update, @goal end |
#index ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/flyboy/goals_controller.rb', line 10 def index :list, Goal @goals ||= Goal.all @order ||= sortable_column_order do |column, direction| case column when "title" %(LOWER(flyboy_goals.#{column}) #{direction}) else params["sort"] = "status" "status ASC" end end @filters ||= SmallData::FilterForGoals.new() @goals = @goals.order(@order) @goals = @filters.apply @goals end |
#new ⇒ Object
35 36 37 38 39 |
# File 'app/controllers/flyboy/goals_controller.rb', line 35 def new @goal ||= Goal.new :create, @goal end |
#open ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'app/controllers/flyboy/goals_controller.rb', line 81 def open if @goal.open! flash[:success] = t("messages.goals.open_ok") else flash[:danger] = t("messages.goals.open_error") end redirect_to @goal end |
#show ⇒ Object
31 32 33 |
# File 'app/controllers/flyboy/goals_controller.rb', line 31 def show :read, @goal end |
#update ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/flyboy/goals_controller.rb', line 58 def update :update, @goal if @goal.update_attributes(goal_params) flash[:success] = t("messages.goals.update_ok") if @goal.closed? redirect_to goals_path else redirect_to @goal end else render :edit end end |