Weihang Jian
Weihang Jian

Reputation: 8755

How to avoid conflicting when naming model attributes?

I want to know if there is a best to name model attribute that won't conflict with ActiveRecord::Base instance methods.

For example, we probably won't name attribute as class or toggle, since these names have already been taken. But how do I simply know if the name is conflicted when generating a model? Any ideas?

Upvotes: 0

Views: 204

Answers (1)

Billy Chan
Billy Chan

Reputation: 24815

Fire your console at first

 > a = MyModel.new
 > a.methods.grep(/my_attr/)

If nothing, nice, you can use my_attr

Upvotes: 3

Related Questions