This is a tough question to answer. Basically it falls under the "Can
you admin using DRY"
Personally I try to create a different layout or use <% if
user.is_admin? %> blocks in the view.
Basically, you can do it any way, however to avoid rewriting as much
code as possible I use the if block method.
Here''s one resource I found right away.
http://www.ruby-forum.com/topic/136715
On May 29, 11:47 pm, "M. Sh"
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Hi,
>
> I am trying to figure out what the best practice for the following
> problem might be: In my RoR app, I have an account class, and the user
> has to have the ability to edit it (e.g., change the email address). At
> the same time, I want to give an admin the chance to edit it, because,
> well, the targeted users might not be clever enough to do everything on
> their own ;-)
>
> Of course, the editing pages should look differently (different menu,
> and also a different redirect after editing is complete). As a rails
> newbie, I can figure out two basic ways of doing this:
> - use the same controller, and change the page layout and redirect_to
> according to some information stored in the session
> - use the same view, and have a different controller and layout for the
> user and the admin
>
> I am not quite sure which way should be preferred - the first one
> amounts to some case distinctions in the view and the controller, which
> I do not like too much, and the second one produces redundant code in
> the two controllers. Any suggestions, or maybe even a third possibility?
>
> Thank you very much!
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
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
-~----------~----~----~----~------~----~------~--~---