Home
> Ruby on Rails > Creating a record with your intended id
Creating a record with your intended id
In Rails, you can create a new record with the methods create; or new followed by save. In both cases, the id of the record is automatically allocated. This is how you can allocate your own id in a new record. Why do we need that? Well, I did, and someone probably need too. For me, it’s a long story. So I’ll just go into the How-to.
[Peep Code]
s = Status.new(:name => ‘New’)
s.id=Status::NEW
s.save
[End of Peep Show]
Now you know why? 🙂
Categories: Ruby on Rails
Comments (0)
Trackbacks (0)
Leave a comment
Trackback