Installing outside of Rails may not be working?
Closed this issue · 4 comments
I'm trying to use Edge outside of Rails. I love the idea. I'm having trouble getting all the features to work. Some of them work which makes me think the problem is that I'm running AR outside of Rails.
For example I can run ".find_forest" and get back the root of my forest. But when I run ".with_descendents" I get back NoMethodError: undefined method 'with_descendents' for #<Tag::ActiveRecord_Relation:0x007fd06bd2d690>
.
I have an AR class "Tag" which has the "acts_as_forest" directive in it. Tag has a "parent_id" integer field. But running code like
Tag.where(name: "Medical Care").with_descendents.all
Yields the NoMethodError above.
Any thoughts?
It should work fine outside of Rails. The specs only bring in ActiveRecord. There is a spec for something similar to what you are doing it it is currently passing (https://github.com/jackc/edge/blob/master/spec/forest_spec.rb#L208).
Can you post a test case?
Oh, and try updating to the latest version of edge. When I was investigating this issue I noticed that tests that used to pass were now failing. It seems that arel or something changed out from under me. Anyway, I fixed those failures so perchance it will resolve your issue as well.
Thanks! I installed the head revision of edge directly from Github and it works perfectly now! Thanks. I'll close this ticket since it's working for me now.
Hopefully you'll push this version to the public gem hub when you get chance! In the meantime it works for me.
FYI to others who need to get this working via Bundler/Gemfile:
Add this to your Gemfile:
gem 'edge', :git => 'git://github.com/JackC/edge'
Run bundle install
per normal.
Add this to your require statements (wherever you manage them):
require 'bundler'
Bundler.setup
require 'edge'
FYI, I released v0.4.0 with the current head revision.