Ruby on Rails Tuesday, January 4, 2011

On Jan 3, 12:04 pm, Mike C <snib...@gmail.com> wrote:
> Thanks for the advice, I didn't know about cancan, it looks like it'll
> make things a lot easier for me. As for the resources, that's the case
> except when I want to create a new resource. The to-be child doesn't
> have a parent yet since it doesn't exist at the moment so I'd have to
> pass the parent or its ID when I want to create a new resource. But in
> general is there a limit to how many levels an app should have?
>

Its not necessarily authoritative, but here's an article that I like
that suggests limiting to two levels max: http://weblog.jamisbuck.org/2007/2/5/nesting-resources.
Usually a given resource only needs to be nested below its parent (for
create as you mention, for index if that's important, and for the
member actions if you want the scoping for some reason), so if you
have A has_many B has_many C, then expose:

As
As/1/Bs
As/1/Bs/2
Bs/2/Cs
Bs/2/Cs/3

No need for As/1 on those last two usually unless it really is unique
in describing the resource.

Also, for authorization you can also look at
declarative_authorization; I often forget about this site, but its
pretty nifty for seeing what's hip: http://www.ruby-toolbox.com/categories/rails_authorization.html

\Peter

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment