# Coding form variations for object creadtion and CRUD

**URL:** <https://www.ruby-forum.com/t/coding-form-variations-for-object-creadtion-and-crud/160533>\
**Category:** Rails\
**Created:** [February 17, 2009, 2:21pm UTC](https://www.ruby-forum.com/t/coding-form-variations-for-object-creadtion-and-crud/160533 "2009-02-17T14:21:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scudco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@scudco](https://www.ruby-forum.com/u/scudco)\
**Post date:** [February 17, 2009, 2:21pm UTC](https://www.ruby-forum.com/t/coding-form-variations-for-object-creadtion-and-crud/160533/1 "2009-02-17T14:21:19Z")

</div>

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  
events.

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  
controller?

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.

---

<div class="post-metadata">

**Author:** ![scudco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@scudco](https://www.ruby-forum.com/u/scudco)\
**Post date:** [February 17, 2009, 2:26pm UTC](https://www.ruby-forum.com/t/coding-form-variations-for-object-creadtion-and-crud/160533/2 "2009-02-17T14:26:37Z")

</div>

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 [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

If you’re using mass assignment, you can keep a single, simple create  
method  
and then each form can just send through more parameters (make sure all  
the  
fields for the detailed version are optional in your model)

def create  
task = Task.new(params[:task])  
if task.save  
#success  
else  
#failed  
end  
end

Then both of these could work  
post :create, :task =\> {:title =\> ‘Test’}  
and  
post :create, :task =\> {:title =\> ‘Test’, :location =\> ‘Here’, :due =\>  
Time.now}

Andrew T.  
[http://ramblingsonrails.com](http://ramblingsonrails.com)  
[http://www.linkedin.com/in/andrewtimberlake](http://www.linkedin.com/in/andrewtimberlake)

“I have never let my schooling interfere with my education” - Mark Twain
