stffn/declarative_authorization — pull request #152 by jhawthorn (2012-08-12 21:24:55+00:00)
Title: Avoid adding temporary object to association proxy

This is an alternative commit to pull request #147, and there is some discussion of this approach in that request.

This prevents the temporary object used for testing permissions from being added to the association proxy by calling .scoped.new instead of simply .new. This should still fill in the appropriate values.

With .new

>> u = User.first
User Load (0.4ms) SELECT `users`.* FROM `users` LIMIT 1
=> #> u.comments.new
=> #
=> #> u.comments
=> [#]

vs .scoped.new

>> u = User.first
User Load (0.4ms) SELECT `users`.* FROM `users` LIMIT 1
=> #> u.comments.scoped.new
=> #
=> #> u.comments
=> []