Hi,
I have to use non default primary key in one of my projects. If i save the
record, the primary key is not getting updated.
For example, consider
*post.rb*
class Post < ActiveRecord::Base
set_primary_key :ida2a2
end
*schema.rb*
create_table "posts", :id => false, :force => true do |t|
t.integer "ida2a2"
t.string "title"
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
end
*In console*
>> p = Post.new(:ida2a2 => 1, :title => "First Post", :body => "jsust a test
i")
=> #<Post ida2a2: nil, title: "First Post", body: "jsust a test i",
created_at: nil, updated_at: nil>
>> p.save
=> true
>> p
=> #<Post ida2a2: 1, title: "First Post", body: "jsust a test i",
created_at: "2008-12-24 08:23:53", updated_at: "2008-12-24 08:23:53">
>>
?> Post.first
=> #<Post ida2a2: nil, title: "First Post", body: "jsust a test i",
created_at: "2008-12-24 08:23:53", updated_at: "2008-12-24 08:23:53">
>>
After saving, ida2a2 becomes nil.
Tried with different combination's, but no success. Can somebody help me
here.
Thanks,
Sudhakar.M
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---