Created
July 14, 2014 15:22
-
-
Save kshsieh/6b399a8474b51ec36cbd to your computer and use it in GitHub Desktop.
controller!
This file contains hidden or 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 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