Multiple instances same model same view

Hi everyone

I wanna know, if possible, how can I create multiple instances of one
and only one model using the same view.
eg

Model users (with no other associations) and I want to create several
users using the “form” to create users at the same time

New User

name_______________ email__________________ (user 1)

name_______________ email__________________ (user 2)
.
.
.
.

add new user (link or button)

Submit (button)

On Jul 21, 2011, at 3:07 PM, Angelo C. wrote:

Hi everyone

I wanna know, if possible, how can I create multiple instances of one
and only one model using the same view.
eg

yes - break the problem down into steps IE:

create a new User with

create 2 new Users with one Form

create a new user form field entry (like the 2nd one above) through
javascript

create 3 new users + one by clicking the link.


Here is an example of a cucumber test for the 2nd part
Given I am on new user page
When I fill in ‘sam’ for ‘user[name]’
When I fill in ‘[email protected]’ for ‘user[email]’
When I press ‘Create’
Then I should see ‘created (1) user’

The second part is a bit more interesting.


It helps to know this about FORMS and RAILS
(don’t mind the \ )

$curl -d object[cake][]=content&object[cake][]=content2
localhost:3000/things

results in
Parameters: {“object”=>{“cake”=>[“content”, “content2”]}}

This concept can be applied to the name of your input property - they
can all have the same
name!





The server will be posted something like :

user[name][]=1
user[name][]=3
user[name][]=3
user[name][]=4
user[name][]=54


The rails server when it sees this stores a hash in ‘params’
with the following structure.


=> {user: { name: [ 1,3,3,4,53] }