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
95 96 97 98 99 100 101 102 103 |
# File 'app/controllers/flyboy/goals_controller.rb', line 95 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
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/flyboy/goals_controller.rb', line 45 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
78 79 80 81 82 83 |
# File 'app/controllers/flyboy/goals_controller.rb', line 78 def destroy :delete, @goal @goal.destroy redirect_to goals_path end |
#edit ⇒ Object
58 59 60 |
# File 'app/controllers/flyboy/goals_controller.rb', line 58 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
39 40 41 42 43 |
# File 'app/controllers/flyboy/goals_controller.rb', line 39 def new @goal ||= Goal.new :create, @goal end |
#open ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'app/controllers/flyboy/goals_controller.rb', line 85 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 |
# File 'app/controllers/flyboy/goals_controller.rb', line 35 def show :read, @goal end |
#update ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/flyboy/goals_controller.rb', line 62 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 |