On Jun 25, 2011, at 8:38 PM, ylluminate wrote:

> Is there a list of attribute names to avoid for models?  For example,
> I stumbled upon a problem when using the name "type :string."  It is
> simply not appearing when I attempt to enter data or edit the entry.
> I assume that perhaps even though I get no complaints, there may be
> some key words there that we should avoid.

'type' is an especially nasty one, as Rails uses it for 
single-table-inheritance (STI). Definitely don't use that one, unless you 
actually intend to do STI (and then you won't need to declare it, as Hobo will 
create it automatically).

Most of the "watch out" things are pretty obvious - anything that's an instance 
method of ActiveRecord::Base is RIGHT OUT. Not typically a problem, but I've 
seen people on rails-talk run into some especially bizarre errors when they 
tried to name a database field 'attributes'.

There are a handful of others that will cause the field spec DSL to get 
indigestion, mostly from stuff that's stashed in the Kernel module and then 
made private for everything else. For instance, Rake has caused some people 
problems since it injects a private 'task' method into Kernel, and the built-in 
FileUtils module has a couple others. You'll know you've hit one when you get a 
"attempt to call private method "foo" on SomeClass" error.

This page has a semi-comprehensive list:

http://wiki.rubyonrails.org/rails/pages/reservedwords

--Matt Jones

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers?hl=en.

Reply via email to