[Rails] Re: Recommended way of restricting action permissions?

2008-12-19 Thread Lisa Klein
Thanks a lot for the replies! I guess I kind of prefer the before_filter method a little bit because then I don't have to replicate the redirect_if_not_found logic in each restricted action. Thanks again! --~--~-~--~~~---~--~~ You received this message because you

[Rails] Recommended way of restricting action permissions?

2008-12-19 Thread Lisa Klein
Hi, I just have a "best practices" question. I'd like to block users that don't own a particular resource from performing edit/update/ destroy actions on it. Here's how I currently do it: ## User has many resources, of different types --- resource_controller.rb --- before_filter :requ

[Rails] Re: Correct way to build an AR object with multiple associations?

2008-12-18 Thread Lisa Klein
Oooh, that clarified a few things. Thanks Andrew! On Dec 18, 4:58 am, Andrew Porter wrote: > Lisa Klein wrote: > > book.user_id = @user.id > > > Is this the way it's supposed to be done?  I know that it's preferred > > to interact with dependent resour

[Rails] Correct way to build an AR object with multiple associations?

2008-12-17 Thread Lisa Klein
I have a Book resource that belongs both to a User and to an Isbn. What is the recommended way of building a new Book record in this type of situation? class Book < ActiveRecord::Base belongs_to :user belongs_to :isbn end Currently I'm doing the following: @isbn = Isbn.find(...) book = @isb