What Ben said is probably the easiest thing to do; generally, if you care about the number (i.e. a requirement that it start from 1) then probably don't use the autoincrement primary key as that number.
As an extra bit I usually stick with as well: don't end the column with "_id", unless it's a foreign key in your system; other devs will like you more when they're refactoring, and also there are various spots where the "_id" gets stripped off for display (the assumption being that it's a foreign key). On Thu, Apr 4, 2013 at 9:09 AM, Clifford Heath <[email protected]> wrote: > On 04/04/2013, at 8:29 AM, Tim Uckun <[email protected]> wrote: >> In my opinion the more you want to do these kinds of things the less >> suitable rails is for your app. Maybe if you swapped out sequel for AR you >> might have an easier time. I think that AR works best when you don't buck >> the system… > > It's not just AR. CPK helps overcome AR's difficulties in this regard, but a > lot > of other things run into difficulties - form helpers like SimpleForm is one. > My position is that while Rails is wrong to be so committed to the surrogate > key concept, if you opt out, you effectively opt out of the whole ecosystem. > > Bottom line: Use a surrogate key *and* a natural primary key almost always. > Join tables with no attributes are the one time you can escape surrogates, > and even those often grow attributes. > > Clifford Heath, Data Constellation, http://dataconstellation.com > Agile Information Management and Design > > -- > You received this message because you are subscribed to the Google Groups > "Ruby or Rails Oceania" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/rails-oceania?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rails-oceania?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
