Welcome to wonderful world of RoR. This incremental ID is probably
the most asked, most answered, most criticized, most … etc issue in
Rails. I’ll give you the answer that I have given countless times.
What makes Rails unique is its approach of “convention over
configuration”. Id is an example of this. Consider you have an entity
called Order with PK id. And another model called Invoice. You might
normally do lots of coding to match those and prevent users from
breaking the link. But in rails, order_id in Invoice will be treated
as a natural link to an order and you’ll be able to 1) Define the
relationship, 2) declare the restrictions rather than code every case
3) Be able to access any time. i.e. Invoice.order.date to access the
The convention over configuration not only prevents you from typing
but helps you by putting constraints in front of you. Constraints, in
coding, regardless of the implied meaning is actually good for your
health. Because you don’t have to make decisions when you have
constraints. You’ll not think while you’re coding to remember if
some field was named tracking_number, tracking_id, track_No etc.
You’ll implicitly write tracking_number and go.
This may sound a bit limiting, and indeed it is. But there’s a trade-
off. You either will stick with the conventions and constrains
implied by them or you’ll have to think about them, document them,
track them, test them, communicate them, and miss the fun part.
Well, the fun part is, rails have evolved as no other web based
technology have by putting one brick over the other based on these
conventions. If you stick with conventions, you’ll be somewhat future-
proof. Just to give you an example, if you had a rails project
complying with the conventions, you may easily convert it to be a
fully-fledged REST web service when it comes up in the new version.
(BTW you can do it now if you’re using Edge Rails, which you’ll need
to be in order to follow the Rails Book v2 )
To cut the long story short, Rails’ power (mostly) lies in the
approach. Rails and Ruby is flexible and powerful if you want to
divert from the convention. BUT until your next project. Also don’t
forget the fact that Rails is best for database backed web applications.
Having said those, I need to add that I’ve been developing web apps
non-EE). The productivity boost is not even close with what I’ve
experienced with Rails.
Disclaimer. Not every type of project is suitable for Rails. You’ll
find yourself going back and forth to other tools. But I hope you’ll
not be disappointed because Rails and the community in general does
not see it as a silver bullet.
Hope this helps.