Created
August 24, 2013 21:28
-
-
Save abriening/6330507 to your computer and use it in GitHub Desktop.
How pretty the Rails 3 controllers can be.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GoalsController < ApplicationController | |
respond_to :html, :json | |
before_action :set_goal, only: [:show, :edit, :update] | |
def show | |
respond_with @goal | |
end | |
def edit | |
respond_with @goal | |
end | |
def update | |
if @goal.update(goal_params) | |
flash[:notice] = 'Goal was successfully updated.' | |
end | |
respond_with @goal | |
end | |
private | |
def set_goal | |
@goal = Goal.find(params[:id]) | |
end | |
def goal_params | |
params.require(:goal).permit(:name, :description, :goal_type) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment