my nested form looks like

<% form_for :doctor, :url => url do |doc_form| %>

  <table>
   <tr>
       <td> <%= doc_form.label :"Specialized Field: " %> </td>
       <td> <%= doc_form.text_field :specialize %> </td>
    </tr>
        <tr>
       <td> <%= doc_form.label :"Medical Center Name: " %> </td>
       <td> <%= doc_form.text_field :working_for %> </td>
    </tr>
                <% doc_form.fields_for :user, :url => url do |f| %>

                <tr>
                   <td> <%= f.label :"First Name: " %> </td>
                   <td> <%= f.text_field :fname %> </td>
                </tr>
                  .....................
I want to display validation errors for both doctor and user...my
create action in the controller looks like

  def create
                doc_attr = params[:doctor]
        user_attr = doc_attr.delete(:user)
                new_doctor = Doctor.new(doc_attr)
                new_doctor.user = User.new(user_attr)
                @saved = new_doctor.save!

                if @saved == true
                        flash[:notice] = "Registration Successful"
                  redirect_to login_path()
                else
                        render :action => 'new'
                end
 end

Thank you

On Oct 12, 5:04 pm, pepe <p...@betterrpg.com> wrote:
> You can't have a form inside of another one. Maybe I am
> misunderstanding?
>
> On Oct 12, 4:22 pm, Dean <deansam2...@gmail.com> wrote:
>
>
>
> > Hi All,
> > I have a nested form
> > OUTER FORM for :doctor
> >  INNER FORM for :user
>
> > I am having problem is displaying the validation errors for both
> > doctor and user model. Any idea about how I should be doing this.
>
> > Thanks alot in advance.
>
> > On Oct 12, 4:16 pm, Dean <deansam2...@gmail.com> wrote:
>
> > > Hi All,
> > > I have a nested form
> > > OUTER FORM for :doctor

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to