On 8 Jun 2010, at 08:37, Roman Catz <trusc...@gmail.com> wrote:

> Hi All,
> 
> I have some strange problem which appears only on heroku hosting 2.3.5
> default stack (not on my local computer)
> I have some models. Here they are:
> 
> class Contact < ActiveRecord::Base
>  belongs_to :user
>  belongs_to :type, :class_name => "ContactType", :foreign_key =>
> "type_id"
> 


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.


Fred




>  validates_presence_of :name, :on => :create, :message => "can't be
> blank"
>  validates_presence_of :type, :on => :create, :message => "can't be
> blank"
>  validates_presence_of :number, :on => :create, :message => "can't be
> blank"
> end
> 
> class ContactType < ActiveRecord::Base
>  validates_presence_of :name
>  validates_uniqueness_of :name
> end
> 
> migration:
>    create_table :contacts, :force => true do |t|
>      t.integer :user_id
>      t.integer :type_id
>      t.string  :name
>      t.string  :number
> 
>      t.timestamps
>    end
>    add_index :contacts, :user_id
> 
> 
>    create_table :contact_types, :force => true do |t|
>      t.string :name
> 
>      t.timestamps
>    end
>    end
> 
> And a simple form:
> <% form_for(@contact) do |f| %>
>  <%= f.error_messages %>
>  <p>
>    <%= f.label :name %>
>    <%= f.text_field :name %>
>  </p>
> 
>  <p>
>    <%= f.label :type_id %>
>    <%= f.collection_select(:type_id, @contact_types, :id, :name) %>
>  </p>
> 
>  <p>
>    <%= f.label :number %>
>    <%= f.text_field :number %>
>  </p>
>  <p>
>    <%= f.submit 'Create' %>
>  </p>
> <% end %>
> 
> If i'm trying to save model and I get
> There were problems with the following fields:
> Contact can't be blank
> 
> What does it mean {model name} can't be blank?
> When I try it local all save well.
> 
> Great Thanks.
> 
> -- 
> 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.
> 

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