Tuesday, June 8, 2010

[Rails] [Rails Heroku] Problem with saving object (on heroku hosting)

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"

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate