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
109 110 111 112 113 114 115 116 117 |
# File 'app/controllers/flyboy/goals_controller.rb', line 109 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
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/flyboy/goals_controller.rb', line 59 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
92 93 94 95 96 97 |
# File 'app/controllers/flyboy/goals_controller.rb', line 92 def destroy :delete, @goal @goal.destroy redirect_to goals_path end |
#edit ⇒ Object
72 73 74 |
# File 'app/controllers/flyboy/goals_controller.rb', line 72 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 30 31 32 33 |
# 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", "status" %(LOWER(flyboy_goals.#{column}) #{direction}) when "progress" %(flyboy_goals.#{column} #{direction}) else params["sort"] = "status" "status ASC" end end @filters ||= SmallData::FilterForGoals.new() @goals = @goals.order(@order) @goals = @filters.apply(@goals) @goals = @goals.search(params[:q]) @goals = @goals.page(params[:page]) end |
#new ⇒ Object
53 54 55 56 57 |
# File 'app/controllers/flyboy/goals_controller.rb', line 53 def new @goal ||= Goal.new :create, @goal end |
#open ⇒ Object
99 100 101 102 103 104 105 106 107 |
# File 'app/controllers/flyboy/goals_controller.rb', line 99 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
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/flyboy/goals_controller.rb', line 35 def show :read, @goal @order ||= sortable_column_order do |column, direction| case column when "title", "status" %(LOWER(flyboy_tasks.#{column}) #{direction}) when "progress", "term" %(flyboy_tasks.#{column} #{direction}) else params["sort"] = "term" "term ASC" end end @tasks = @goal.tasks.order(@order) end |
#update ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/controllers/flyboy/goals_controller.rb', line 76 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 |