Created
January 10, 2012 17:18
-
-
Save jlebrech/1590087 to your computer and use it in GitHub Desktop.
what is wrong with my before filter
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 ChaptersController < ApplicationController | |
before_filter :check_ownership_of_chapters_book | |
def check_ownership_of_chapters_book | |
#abort(params.to_yaml) | |
=begin | |
--- | |
utf8: ✓ | |
authenticity_token: NwsHY5ex9ynzXfDSXiQ8EBps6Yhzxf0iPPbJPWLkTtg= | |
chapter: | |
title: test | |
content: '' | |
book_id: '1' | |
action: create | |
controller: chapters | |
book_id: '1' | |
=end | |
if Book.find(params[:book_id]).author != current_user | |
flash[:error] = "You are not the author of the book you are adding the chapter to" | |
redirect_to root_url | |
end | |
# Couldn't find Book without an ID | |
# how come when when the params have book_id: '1' ? | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment