This project is archived and is in readonly mode.
habtm join requires an active connection
-
Russell Garner
I'm seeing this too - association declaration below. Is there a recommended workaround?
has_and_belongs_to_many :related_tags, :class_name => 'SemanticallyTaggable::Tag', :association_foreign_key => 'related_tag_id', :join_table => 'related_tags', :insert_sql => 'INSERT INTO related_tags (`tag_id`, `related_tag_id`) VALUES (#{id}, #{record.id}), (#{record.id}, #{id})', :delete_sql => 'DELETE FROM related_tags WHERE (tag_id = #{id} AND related_tag_id = #{record.id}) OR (tag_id = #{record.id} AND related_tag_id = #{id})' -
Russell Garner
Here's my (not very good) workaround:
after "require "rails/all" in application.rb
database_yml = File.expand_path('../database.yml', __FILE__) if File.exists?(database_yml) active_record_configuration = YAML.load_file(database_yml)[Rails.env] ActiveRecord::Base.establish_connection(active_record_configuration) else raise "Please create #{database_yml} first to configure your database." endHowever, the habtm in question is being defined in a gem, which makes it harder than it needs to be for people to add a reference to the gem. Still open to much better suggestions than mine :)
-
Russell Garner
Ok, a quick
autoloadon the offending class also works very well in a Railtie and obviates the need for the above hackery :) -
Russell Garner
Don't know why I mentioned a Railtie there. One is not required...
-
rails
- State changed from new to open
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
rails
- State changed from open to stale