-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Help understanding limitations with Rails and Solargraph #188
Comments
One issue with your .solargraph.yml: the paths in the Solargraph doesn't know that One workaround is to identify the variable type with a # @type [Person]
person = Person.find(100)
person.my_a # <- works |
Thank you for your reply. I've fixed the I'm curious how other users of Rails and Solargraph deal with this issue? My imagined workaround at this point is to create a module (
Kind of a hassle but not a lot of work -- copy paste and find replace all. But I wonder if there is a better way to get this functionality? The real hassle would be adding a new |
One thing that could make it a little cleaner is using YARD directives to generate the documentation without modifying the actual code. There are currently a couple bugs in the way directives get parsed (see #176) that I plan to have fixed in gem 0.33.0, but there's a workaround for now. You can use the # @!parse
# class Person
# def self.find(*args)
# Person.new
# end
# end The problem with In version 0.33.0, you'll also be able to do it with the class Person
class << self
# @!method find(*args)
# @return [Person]
end
end There's an even better way that's in the works. It would make the most sense to use the class ActiveRecord::Base
class << self
# @!method find(*args)
# @return [self]
end
end That way, any class that extends The YARD tags overview might give you some other ideas. |
Thanks for the insight again -- looking forward to |
It looks like this is working now in 0.33 ! Woot! Thank you! Quick follow up question ... is this the correct way to do it for
PS:I noticed when I used Thank you thank you thank you! |
Glad you got it working! I've been using For I encountered the same bug with multiple |
Yea - I kept going back and forth between those two options. Class methods on the model are not available using |
Very new to solargraph so forgive me is this is obvious. I see from #87 that Rails support is still in the pipeline -- but as I am new I want to make sure I am covering my bases.
Is there a way to get instances of a class recognized as belonging to the class they are coming from with methods such as
MyActiveRecord.find()
?For example:
Person.find(1)
(no) vsPerson.my_find()
(yes)Correctly yard doc'd custom methods work:
Rails built-in does not
Is this a problem because Rails is not using YARD formatting for their "find" method? Or with find being inherited ? Or with my setup?
Thanks in advance for any insight.
The text was updated successfully, but these errors were encountered: