Skip to content

Instantly share code, notes, and snippets.

@kshsieh
Created July 14, 2014 15:22
Show Gist options
  • Save kshsieh/6b399a8474b51ec36cbd to your computer and use it in GitHub Desktop.
Save kshsieh/6b399a8474b51ec36cbd to your computer and use it in GitHub Desktop.
controller!
class FakeController < ActionController
before_action :find_fake, only: [:show, :edit, :update]
def index
@fakes = Fake.all
end
def new
@fake = Fake.new
end
def create
@fake = Fake.new fake_params
if @fake.save
redirect_to fakes_path
else
render :new
end
end
def show
end
def edit
end
def update
if @fake.update_attributes fake_params
redirect_to fakes_path
else
render :edit
end
end
private
def fake_params
params.require(:fake).permit(:foo, :bar)
end
def find_fake
@fake = Fake.find params[:id]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment