Created
July 24, 2014 06:55
-
-
Save anonymous/8c5dee06af027888e36f to your computer and use it in GitHub Desktop.
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 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