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:in
`block (2 levels) in <class:Railtie>'

  Can you please advise how this issue can be fixed?

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:in

`block (2 levels) in class:Railtie

Can you please advise how this issue can be fixed?


Posted via http://www.ruby-forum.com/.

The error is this:

ActiveRecord::Base::DEFAULT_ENV (NameError) 

How does your config/database.yml look like?

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 Jones

Matt Jones wrote in post #1146177:

  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 Jones

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