Skip to content

Instantly share code, notes, and snippets.

Created July 24, 2014 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/8c5dee06af027888e36f to your computer and use it in GitHub Desktop.
Save anonymous/8c5dee06af027888e36f to your computer and use it in GitHub Desktop.
class BooksController < ApplicationController
before_filter :authenticate_user!
def index
@books = current_user.books
end
def new
@book = Book.new
end
def create
@book = Book.new(book_params)
if @book.save
redirect_to root_path, notice: "Book created"
else
render :new
end
end
private
def book_params
params.require(:book).permit(:title)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment