On Nov 11, 9:46 am, Raji Mani <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I have view page which takes all the information like contact's emails ,
> phones no's etc and saves different tables. I want to save more than one
> email id's for a particular contact.
>
> view page is something like this..
>
There's two separate problems here:
- how you manage the ui, ie adding extra textfields to the page
- how you convince rails to treat these textfields as an array.

The key to the second part is how you name the parameters. In
particular parameters ending with a [] are treated as arrays.

Fred
> .
> .
> Email 1 :
> <%= select 'email', 'email_type', %w(Business Personal), :include_blank
> => false %>
> <%= text_field 'email','email',:size=>"35",:maxlength=>"80" %>
> <%= radio_button 'email', 'isprimary', '1' %>Primary
> Email 2 :
> <%= select 'email', 'email_type', %w(Business Personal), :include_blank
> => false %>
> <%= text_field 'email','email',:size=>"35",:maxlength=>"80" %>
> <%= radio_button 'email', 'isprimary', '1' %>Primary
> .
> .
>
> Controller is :
>
> def create
>       @contact = Contact.new(params[:contact])
>       @contact.emails << Email.new(params[:email])
>       @contact.phones << Phone.new(params[:phone])
>       @contact.addresses << Address.new(params[:address])
>       puts "hellooooooo bharati"
>       params.inspect
>       if @contact.save
>          flash[:notice] = "Contact was successfully created."
>          redirect_to :action => 'list'
>       else
>          render :action => 'new'
>                   flash[:notice] = "Contact was not created."
>       end
>    end
>
> Can any one help me how to send more than one email ids to controller..
> --
> Posted viahttp://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