Skip to content

Avoid loading Database on acts_as_tree declaration #54

@matthewrudy

Description

@matthewrudy

Right now when doing rake assets:precompile with no database
I get an exception:

PG::ConnectionBad: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
...
/usr/local/bundle/gems/activerecord-5.0.0.1/lib/active_record/attribute_methods/primary_key.rb:73:in `primary_key'
/usr/local/bundle/gems/acts_as_tree-2.5.0/lib/acts_as_tree.rb:68:in `acts_as_tree'

This was introduced in #52

And is caused by:

def acts_as_tree(options = {})
  configuration = {
    primary_key:   primary_key,
    ...
  }

  configuration.update(options) if options.is_a?(Hash)
  ...
end

Because that primary_key is always hit
I can't even override it.

Maybe

configuration = {}
configuration[:primary_key] = options[:primary_key] || primary_key
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions