Forum: Ruby on Rails coding form variations for object creadtion and CRUD

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Adam A. (Guest)
on 2009-02-17 15:21
I want to provide the user with two ways to add a task. The quick way
and the detailed way pretty much like google calendar allows for its

On clicking the "Add Quickly" link a form with just a title field
appears immediately below.
For "Add Detailed" the user is taken to a new page where a form with
fields for title, due, location etc

Im wondering in my controller should I create two new actions i.e.
new_quick and new_detailed

or should I somehow (not sure how) just use logic in the one new

Im fairly new to rails so just trying to stick to best practices. Ive
implemented these already in a slapshot way and using link_to_remote but
just want to tidy it up as much as possible.

Any help greatly appreciated.
Andrew T. (Guest)
on 2009-02-17 15:26
(Received via mailing list)
On Tue, Feb 17, 2009 at 3:21 PM, Adam A. <
removed_email_address@domain.invalid> wrote:

> Im wondering in my controller should I create two new actions i.e.
> Any help greatly appreciated.
> --
> Posted via
> >
If you're using mass assignment, you can keep a single, simple create
and then each form can just send through more parameters (make sure all
fields for the detailed version are optional in your model)

def create
  task =[:task])

Then both of these could work
  post :create, :task => {:title => 'Test'}
  post :create, :task => {:title => 'Test', :location => 'Here', :due =>}

Andrew T.

"I have never let my schooling interfere with my education" - Mark Twain
This topic is locked and can not be replied to.