Skip to content

Instantly share code, notes, and snippets.

@jlebrech
Created January 10, 2012 17:18
Show Gist options
  • Save jlebrech/1590087 to your computer and use it in GitHub Desktop.
Save jlebrech/1590087 to your computer and use it in GitHub Desktop.
what is wrong with my before filter
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