I usually use the same partial for creating and editing, what you said is
about right, I usually just do;
*fields that are used for both creating and updating*

% if @user.new_record? %>
    %= submit_tag 'Create' %>
% else %>
    %= submit_tag 'Update' %>
% end %>


and then throw in whatever else you need to like back buttons or whatever.
For updating the password, you can either just have the two password fields,
which will update the passwords if a new one is set, or you can do another
if @user.new_record? statement in the form and have it show the fields for
creating a password or updating a password.

Hope this helps.


On Tue, Dec 30, 2008 at 5:53 PM, Clem Rock <[email protected]
> wrote:

>
> What I'm trying to accomplish is this.  I have a simple layout called
> main.erb.html with a catch all <%=yield %> for content.
>
> I keep running into the situation where so many actions' partials are so
> similar it seems ridiculous to keep re-creating one for every action.
> I would like to do something like this:
>
> I have these actions:
>
> create_users,
> update_users
> update_user_password
>
> Instead of creating 3 partials, it would be nice to use 1 partial and
> just show certain fields like this:
>
> %=if controller.action_name == 'create_users' %>
>  Show these fields
> <% end -%>
>
> %=if controller.action_name == 'update password' %>
>  Show these fields
> <% end -%>
>
> ect.
>
>
>
>
> Robby Russell wrote:
> > Are you familiar with content_for ?
> >
> > <%= yield :list_roles -%>
> >
> > <% content_for :list_roles, 'content here' -%>
> >
> > or as a block
> >
> > <% content_for :list_roles do %>
> >   content here...
> > <% end %>
> >
> > Cheers,
> > Robby
> >
> > On Fri, Dec 26, 2008 at 12:15 PM, Clem Rock
> > <[email protected]> wrote:
> >> If I try to use render :partial => 'list_roles' in the create method,
> >> --
> >> Posted via http://www.ruby-forum.com/.
> >>
> >> >
> >>
> >
> >
> >
> > --
> > Robby Russell
> > Chief Evangelist, Partner
> >
> > PLANET ARGON, LLC
> > design // development // hosting w/Ruby on Rails
> >
> > http://www.planetargon.com/
> > http://www.robbyonrails.com/
> > aim: planetargon
> >
> > +1 503 445 2457
> > +1 877 55 ARGON [toll free]
> > +1 815 642 4068 [fax]
>
> --
> Posted via http://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 [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