One of the most confusing causes of bugs in Rails apps is when names collide with Rails conventions.
Here’s a few places that I can think of:
###Model
- Don’t name any columns ending with
_id
unless these are foreign keys and integer values. If you use the nilify_blanks gem, which is super useful when you have tables with unique indexes that allow nulls, then columns ending with_id
and_count
are ignored by default. - Don’t name any column
type
, as that’s reserved.
###Controller
- Don’t accidentally create any controller methods that end in
_url
or_path
as those will conflict with route helpers.
What other names are reserved in Rails? What sort of subtle bugs have you seen related to this?
http://forum.railsonmaui.com/t/avoiding-confusing-naming-issues-in-rails/119/1