? concerning ActiveRecord, Action and template

Much appreciate any help here. I’m just getting started learning RoR and
setting up my first form is throwing me - I’m not getting the concepts
formalized in my mind.


  • Controller is: Donation
  • Action is: donation_entry
  • Template is: donation_entry.rhtml

This form will be displayed when selected from sidebar menu (which will
always be present for all forms). As such it will be blank for adding a

This form will also be displayed when selecting a donation record from
another form, in which case the record selected will be displayed as

My understanding is that I need a template/form named
donation_entry.rhtml, which I have, but I also need a template/form for
every action in my controller.

I don’t want this.

What I want is this:

Scenario One:

User selects Donation from sidebar menu. Blank form is displayed, user
enters data and hits submit. Record is added to the database and form
remains displayed with data just entered as is - allowing updating.

Scenario Two:

User selects this record off list in another form. Donation_entry form
is displayed with this record. User modifies data and hits submit. The
record is left displayed on form as is - same as when adding a record.


In DonationController, action method donation_entry, couldn’t I do the
following, thus avoiding two or three templates/forms - one for each
action, if I have just the one action of donation_entry:

def donation_entry (in psuedo code)
if new_record
add record
if save record
if update_record

In case you are wondering, if the user wanted to immediately add a
second donation record, they would select Donation off the sidebar menu.

I hope this is sufficient information. Any help is very much

Thanks in advance.

Kee (Scott)

Sounds fairly simple. You want the form to be shared across multiple
actions. Correct? What you want is a partial that contains your form.
out out wiki, and other tutorials on www.rubyonrails.com. Partials are
a lot, and are very handy.


p.s. If you generate scaffolding it uses partials for all its stuff. I
recommend studying that code and see how its done. Scaffolding is a
place to start learning.

Thank you Nick. I will give it a shot.