Hi Doug,

On Fri, 2009-08-21 at 11:22 -0700, doug wrote:
> I have an @member object (e.g., @member=Member.find(5)) with which I
> am doing the basic CRUD stuff.  Records can be modified by either the
> administrative user or by other users in their "profile" settings.
> The two views are very similar but not identical.  In an attempt to
> keep my code DRY, I am trying to use a single view which gets shaped
> into the proper form by a couple of parameters appended to the URL.

Not sure what you mean by 'a single view'.  In general, we tend to use
partials to refactor out duplication in views.

> Without validation it all works perfectly.
> 
> Here's the problem.  With validation added, I need to render the view
> in order to have error messages displayed.  However, I need to use
> redirect_to in order to pass the needed parameters in the URL.  

Where are you redirecting to?  Above you say 'the two views' which, to
me, implies two controllers.  Yes?  No?  Explain, please.

> In googling the issue, one commentator suggested saving the @member
> object in either a flash or session variable.  The idea sounded good;
> but, it didn't work.  Virtually everything else that I read on google
> seemed to say that one needs to use render in order to access the
> error messages.

If you redirect you'll lose the errors.  A redirect creates an entirely
new request / response cycle and @errors is an instance variable.  You
could save it in the session, but I wouldn't.  It's cleaner just to have
two views, one for your admin controller and one for the other, that use
a common partial for DRY purposes, and let Rails do it's thing.  But
then, I may be misunderstanding what you're trying to do entirely.

> Anyway, my question is this:  How should I be approaching this issue?

HTH,
Bill


--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to