Comments (11)
I have the same problem, but it only occurred after adding the gem 'cells' to my Gemfile. I'm on Rails 3.0.3.
from default_value_for.
I'm on Rails 3.0.4 and this happens to me when I have the acts_as_audited 2.0.0.rc7 and default_value_for in my gemfile. Separately, they both work fine. You can easily replicate the problem by making a boilerplate Rails app, making the Gemfile look like https://gist.github.com/edd2f596a5e9ff11b880 , and trying to open the rails Console.
$ rails c
/opt/local/lib/ruby/gems/1.8/gems/default_value_for-1.0.1/lib/rails.rb:23: uninitialized constant ActiveRecord (NameError)
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/all.rb:1:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/all.rb:1
from /Users/john/trash/config/application.rb:3:in `require'
from /Users/john/trash/config/application.rb:3
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/commands.rb:21:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/commands.rb:21
from script/rails:6:in `require'
from script/rails:6
Maxwell:trash john$
from default_value_for.
I think the problem is the presence of rails.rb inside lib.
My understanding is that when rubygem loads default_values_for it adds 'default_values_for/lib' to the ruby load path. Then when someone tries to "require 'rails'" they may get 'default_values_for/lib/rails.rb' instead of the expected 'rails/lib/rails.rb' (depending on the order of the load paths).
Maybe rails.rb could be moved into a subdirectory?
from default_value_for.
I had the same problem and am using the 'cells" gem as well. I've forked and removed the offending file: https://github.com/AndrewO/default_value_for
Although it's kind of hacky, I'm kind of reluctant to spend time figuring out how Rails 2 initializes gems since I just don't need it. Still, it makes me a little nervous, but I'm starting to wonder is Cells is doing something funky. Maybe I'll end up looking into it later.
from default_value_for.
This should be fixed in commit 999ba35. Can anybody confirm?
from default_value_for.
This commit isn't working for me with rails 3.0.5.
I'm able to get it to work by manually requiring 'default_value_for/railtie' in my config/application.rb below the Bundler.require line so the railtie seems to be defined correctly. I think what is missing is a 'lib/default_value_for.rb' file that requires 'lib/default_value_for/railtie' when the constant 'Rails::Railtie' is defined. Something like this maybe?
# in file lib/default_value_for.rb
require 'lib/default_value_for/railtie' if defined? Rails::Railtie
I might even go further and:
- move lib/default_value_for/core.rb back to lib/default_value_for.rb,
- put the above require at the top of the file, and
- remove the require from init.rb
I'll test this and submit a pull request.
from default_value_for.
I sent a pull request here: #13
from default_value_for.
Thanks, I've merged your pull request. Can anybody else confirm that this works on Rails 3 as well as Rails 2? As soon as I have these two confirmations I will release.
from default_value_for.
I'm using 1bc2825 on a Rails 3 project right now. I'm not getting the problem I was having earlier, so I think the Rails 2/3 initialization bug has been sorted out. (I'm having a different problem, but I think it's unrelated or may just be my fault.)
from default_value_for.
With 'cells' gem attached in Gemfile this problem still occurs.
from default_value_for.
I've confirmed that the problem is fixed. mlitwiniuk, if please open a separate bug report with details if you're still experiencing problems.
from default_value_for.
Related Issues (20)
- Sign and push 3.0.1 gem to rubygems HOT 3
- `method_missing': undefined method `default_value_for'... HOT 8
- factory_girl compatibility HOT 1
- default_value_for on a non-column attribute doesn't honor initialized attributes when `allows_nil` is false. HOT 1
- Release 3.0.2 with Rails 5 support to Rubygems HOT 1
- ActiveModel::ForbiddenAttributesError on Rails 4.2 HOT 4
- alias_method_chain is deprecated
- Rails 5.1: Relax version spec in gemspec HOT 1
- default_value_for overrides values provided by an ActionController::Parameters object
- Release 3.0.3 with Rails 5.1 support to Rubygems HOT 12
- Upgrade to version 3.0.4 breaks gitlab HOT 5
- Issue with ActiveModel::MissingAttributeError for `allow_nils: true` HOT 2
- Bug in blank attribute detection w/o column backing HOT 2
- Is compatible with Rails 6? HOT 8
- Doesn't work with rails 6 HOT 1
- Fails with wrong number of arguments when used inside a subclass in Ruby 2.6+
- Support for Rails 6.1.0 HOT 4
- Support for Rails 7 HOT 11
- There are more alternative gems than mentioned in the readme
- Support for Rails 7.1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from default_value_for.