-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional checks #82
Conversation
I figured out the same Class === c fix and checked it in yesterday. It's new with 2.3.14, coming from some ActiveSupport method_missing madness. |
In the migration you can write create_table :items_users, :id => false do |t|
t.references :item
t.references :user
end When you create |
@@ -82,7 +82,7 @@ def get_schema_info(klass, header, options = {}) | |||
attrs = [] | |||
attrs << "default(#{quote(col.default)})" unless col.default.nil? | |||
attrs << "not null" unless col.null | |||
attrs << "primary key" if col.name.to_sym == klass.primary_key.to_sym | |||
attrs << "primary key" if klass.primary_key && col.name.to_sym == klass.primary_key.to_sym |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I solve this problem this way:
attrs << "primary key" if col.name.to_sym == klass.primary_key.try(:to_sym)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"try" seems like a fun method. Where is it defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know if we can use ActiveSupport methods since some people use
Annotate without Rails.
On Fri, Jul 13, 2012 at 4:33 PM, arturtr
[email protected]
wrote:
@@ -82,7 +82,7 @@ def get_schema_info(klass, header, options = {})
attrs = []
attrs << "default(#{quote(col.default)})" unless col.default.nil?
attrs << "not null" unless col.null
attrs << "primary key" if col.name.to_sym == klass.primary_key.to_sym
attrs << "primary key" if klass.primary_key && col.name.to_sym == klass.primary_key.to_sym
http://api.rubyonrails.org/classes/Object.html#method-i-try
Reply to this email directly or view it on GitHub:
https://github.com/ctran/annotate_models/pull/82/files#r1163133
Alex Chaffee - [email protected]
http://alexchaffee.com
http://twitter.com/alexch
Would really like to see this merged. I can't annotate any Factory Girl factories without it. |
@adie Thanks for fixing the is_a? bug - I was running into that too. |
Done. Sadly my git fu was not strong enough to properly credit adie so her fork will appear to be dangling, but the fix is in 076e778 |
First check is to support models with no primary key
Also I changed
c.is_a?(Class)
toClass === c
because of the following error:I didn't find the reason of that error, just tried
Class === c
and it worked.And I had to add the last check because of some strange errors from factory_girl:
I've found that it was trying to get ancestors for instance of FactoryGirl::DefinitionProxy, which seems to be making a lot of magic.