Skip to content
This repository has been archived by the owner on Nov 19, 2021. It is now read-only.

Horza does not support object with a field called :method #6

Open
SofianO opened this issue Sep 18, 2015 · 3 comments
Open

Horza does not support object with a field called :method #6

SofianO opened this issue Sep 18, 2015 · 3 comments

Comments

@SofianO
Copy link

SofianO commented Sep 18, 2015

For an active record object with a field/column named 'method', horza returned
ArgumentError: wrong number of arguments (0 for 1)
from (irb):25:in `method'

Perhaps this should be documented?

@BlakeTurner
Copy link

The problem here is that method is both a field name and a method inherited. Horza just sends the method to the AR object, so it's clearly defaulting to the method rather than the field name.

@newton101
Copy link
Contributor

You should not define any method/A.R attribute as "method" unless you intend to override the default implementation, as it could lead to unexpected behaviour.

Regarding documenting it there are two points:

  1. Documenting methods the are available on on every object (as is the method named "method"), doesn't make sense and but rather relies on your understanding of Ruby. It's analogous to you saying don't call a column name "puts".

  2. The Rails documentation already has something on best practice for naming of fields/columns that maybe are not as obvious as the example above.

@SofianO
Copy link
Author

SofianO commented Nov 20, 2015

Indeed this key word is listed as a reserved word in rails
http://reservedwords.herokuapp.com/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants