Composite primary key - Rails 4.1

Hi,

I am facing issue with composite primary key

In my gem file I have the below entries -

gem ‘rails’, ‘>= 4.1.0.rc2’
gem ‘mysql2’
gem ‘rb-readline’, “~> 0.5.1”
gem ‘sdoc’, ‘~> 0.4.0’, group: :doc
gem ‘spring’, group: :development
gem ‘bcrypt’, ‘~> 3.1.7’
gem ‘composite_primary_keys’, {
:git =>
‘git://github.com/composite-primary-keys/composite_primary_keys.git’,
:branch => ‘ar_4.1.x’
}

When I tried running rails server, I get the below error

Exiting
/home/samanth/.bundler/ruby/2.1.0/composite_primary_keys-82db7315760f/lib/composite_primary_keys/connection_adapters/abstract/connection_specification_changes.rb:10:in
establish_connection': uninitialized constant ActiveRecord::Base::DEFAULT_ENV (NameError) from /home/samanth/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-4.1.0.rc2/lib/active_record/railtie.rb:129:inblock (2 levels) in class:Railtie

Can you please advise how this issue can be fixed?

The error is this:

ActiveRecord::Base::DEFAULT_ENV (NameError)

How does your config/database.yml look like?

On Wednesday, 14 May 2014 21:11:54 UTC-4, Ruby-Forum.com User wrote:

gem ‘sdoc’, ‘~> 0.4.0’, group: :doc

Can you please advise how this issue can be fixed?

I think this is an issue with the CPK gem, not Rails. My first suspicion
is
that the file that defines DEFAULT_ENV isn’t being required:

https://github.com/rails/rails/blob/v4.1.0.rc2/activerecord/lib/active_record/connection_handling.rb

Note the bunch of files that are required in the CPK main file:

https://github.com/composite-primary-keys/composite_primary_keys/blob/ar_4.1.x/lib/composite_primary_keys.rb

connection_handling isn’t on that list…

–Matt J.

Matt J. wrote in post #1146177:

On Wednesday, 14 May 2014 21:11:54 UTC-4, Ruby-Forum.com User wrote:

gem ‘sdoc’, ‘~> 0.4.0’, group: :doc

Can you please advise how this issue can be fixed?

I think this is an issue with the CPK gem, not Rails. My first suspicion
is
that the file that defines DEFAULT_ENV isn’t being required:

https://github.com/rails/rails/blob/v4.1.0.rc2/activerecord/lib/active_record/connection_handling.rb

Note the bunch of files that are required in the CPK main file:

https://github.com/composite-primary-keys/composite_primary_keys/blob/ar_4.1.x/lib/composite_primary_keys.rb

connection_handling isn’t on that list…

–Matt J.

Can you please suggest if any work around to get past this error ?

Andreas Wenk wrote in post #1146145:

The error is this:

ActiveRecord::Base::DEFAULT_ENV (NameError)

How does your config/database.yml look like?

The same config/database.yml was working just fine until I installed CPK
gem.

Please find below link where I asked for solution for the same issue.

http://stackoverflow.com/questions/23621722/no-such-file-to-load-active-record-associations-has-and-belongs-to-many-associat

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs