My app currently is working but I'm a little OCD about conforming to
best practices so I'd like to get a few things cleared up.
1. I have quite a lot of before_filters to restrict certain parts of
the site to some users, and a lot of my controllers use very similar
authorization code. Here's an example:
AController
def auth
unless cond1 || cond 2
flash[:error] = 'no access'
redirect_to some_url
end
BController
def auth
unless cond1 || cond2 || cond3
flash[:error] = 'no access'
redirect_to another_url
end
I was thinking of making a new method inside the ApplicationController
and making it a helper method as well so it can be used in all
controllers and all views. Also, I want to know whats the best way to
use respond_with instead of redirect_to in this situation. Do I need
to worry about other formats besides HTML in these before_filters?
Regarding nested resources, is it bad to have more than 2 levels? My
deepest level is 3 and it's a bother to manage it all, but if I
separate them then I'd still have to get the IDs of their "parents"
anyways by passing them in URLs or something.
--
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