Yes of course, currently it looks like

  validates_presence_of :contact_type_id
  validates_associated :contact_type

I insert some debug on the view and get something: please look into
it :)

<% form_for(@contact) do |f| %>
  <%= debug(@contact) %>

The difference here is under

changed_attributes:
  name:
  contact_type_id:
  number:
contact:

what is attribyte    attribute: :contact ?

result:
heroku:

--- &id002 !ruby/object:Contact
attributes:
  name: "44"
  updated_at:
  contact_type_id: "1"
  number: rrr
  user_id:
  created_at:
attributes_cache: {}

changed_attributes:
  name:
  contact_type_id:
  number:
contact:
contact_type: &id001 !ruby/object:ContactType
  attributes:
    name: sms
    updated_at: 2010-06-08 10:57:27.197988
    id: "1"
    created_at: 2010-06-08 10:57:27.197988
  attributes_cache: {}

  errors: !ruby/object:ActiveRecord::Errors
    base: *id001
    errors: !map:ActiveSupport::OrderedHash {}

errors: !ruby/object:ActiveRecord::Errors
  base: *id002
  errors: !map:ActiveSupport::OrderedHash
    contact:
    - !ruby/object:ActiveRecord::Error
      attribute: :contact
      base: *id002
      message: :blank
      options: {}

      type: :blank
new_record: true
user:

local:
--- &id002 !ruby/object:Contact
        attributes:
          number: ""
          name: "444"
          created_at:
          contact_type_id: "1"
          updated_at:
          user_id:
        attributes_cache: {}

        changed_attributes:
          name:
          number:
          contact_type_id:
        contact_type: &id001 !ruby/object:ContactType
          attributes:
            name: sms
            created_at: 2010-06-08 11:02:03
            updated_at: 2010-06-08 11:02:03
            id: "1"
          attributes_cache: {}

          errors: !ruby/object:ActiveRecord::Errors
            base: *id001
            errors: !map:ActiveSupport::OrderedHash {}

        errors: !ruby/object:ActiveRecord::Errors
          base: *id002
          errors: !map:ActiveSupport::OrderedHash
            number:
            - !ruby/object:ActiveRecord::Error
              attribute: :number
              base: *id002
              message: can't be blank
              options: {}

              type: :blank
        new_record: true
        user:


On Jun 8, 2:54 pm, Frederick Cheung <frederick.che...@gmail.com>
wrote:
> On Jun 8, 10:59 am, Roman Catz <trusc...@gmail.com> wrote:
>
> > Thanks Frederick, but I still do not understand what's going on here.
>
> > I changed this line to belongs_to :contact_type ..
> > The result is the same.
>
> Did you also  change the validates_presence_of :type ?
>
> Fred
>
>
>
>
>
> > Controller was generated as standart scaffold.
> > def create
> >   @contact = Contact.new(params[:contact].merge(:user =>
> > current_user))
> >   respond_to do |format|
> >     if(@contact.save)
> >     ...
>
> > Contact can't be blank
> > Do you know when this validation should appear?
>
> > > Your problem may lie here - the type attribute (if present) is used for 
> > > single table inheritance. Obviously this is adding a type method rather 
> > > than an attribute but I would definitely try changing that association 
> > > name.

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