Rails, Devise, and Mongo - Which versions do I use? - ruby-on-rails

I'm currently trying to get a Mongo database running alongside Devise. I'm using Rails 3.2.2 and Ruby 1.9.3, mongo_mapper 0.11.0, devise 1.1.9, and devise-mongo_mapper 0.0.2. I've referred to numerous sources online, but they seem to be invariably outdated.
A huge problem I'm facing right now involves devise-mongo_mapper. With mongod running on the terminal, trying to run the rails server gives me the following:
/usr/local/lib/ruby/gems/1.9.1/gems/devise-1.1.9/lib/devise.rb:193:in `mailer=': undefined method `ref' for ActiveSupport::Dependencies:Module (NoMethodError)
from /usr/local/lib/ruby/gems/1.9.1/gems/devise-1.1.9/lib/devise.rb:195:in `<module:Devise>'
from /usr/local/lib/ruby/gems/1.9.1/gems/devise-1.1.9/lib/devise.rb:4:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
from /home/neilbasu/Desktop/rails_practice_app/onemoremongopractice/config/application.rb:13:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:53:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:53:in `block in <top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:50:in `tap'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I checked online and found this could be because my devise isn't updated. Trying to update it gave me this:
Bundler could not find compatible versions for gem "devise":
In Gemfile:
devise-mongo_mapper (>= 0) ruby depends on
devise (~> 1.1.0) ruby
devise (2.0.4)
So basically, the older devise won't work, and the newest version isn't compatible with my current devise-mongo_mapper. Is there any way around this? Either a way to get all of these programs working together or a way to not need devise-mongo_mapper at all would be great.

Take a look at several of the forks.
They just bumped the version in the gemspec and the code probably works unchanged.

You can install whatever version of the gem you want using the -v argument.
sudo gem install whatever -v 1.0.1
Or you can look at the forks as Plastic Chicken suggested.

I was also facing the same error and running "bundle update" solved my problem.

Related

search_up: undefined method 'untaint' error after Ruby upgrade

amateur coder here. In order to upgrade my Heroku stack, I have to move to a later Ruby version. I followed a tutorial to upgrade to Ruby 3.2.
After the upgrade, any time I try to do anything such as 'rails s' or 'bundle update', I get the error below. I've searched a lot online but can't find much of any use.
Any thoughts?
Many thanks for any tips
ec2-user:~/environment/website (master) $ bundle update
/home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:272:in `search_up': undefined method `untaint' for "/home/ec2-user/environment/website":String (NoMethodError)
current = File.expand_path(SharedHelpers.pwd).untaint
^^^^^^^^
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:259:in `find_file'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:251:in `find_gemfile'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:27:in `root'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/gems/bundler-1.17.3/lib/bundler.rb:234:in `root'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/gems/bundler-1.17.3/lib/bundler.rb:246:in `app_config_path'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/gems/bundler-1.17.3/lib/bundler.rb:273:in `settings'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/gems/bundler-1.17.3/lib/bundler/feature_flag.rb:21:in `block in settings_method'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/gems/bundler-1.17.3/lib/bundler/cli.rb:97:in `<class:CLI>'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/gems/bundler-1.17.3/lib/bundler/cli.rb:7:in `<module:Bundler>'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/gems/bundler-1.17.3/lib/bundler/cli.rb:6:in `<top (required)>'
from <internal:/home/ec2-user/.rvm/rubies/ruby-3.2.0-preview1/lib/ruby/3.2.0+1/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/home/ec2-user/.rvm/rubies/ruby-3.2.0-preview1/lib/ruby/3.2.0+1/rubygems/core_ext/kernel_require.rb>:85:in `require'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/gems/bundler-1.17.3/exe/bundle:23:in `block in <top (required)>'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/gems/bundler-1.17.3/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/gems/bundler-1.17.3/exe/bundle:22:in `<top (required)>'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/bin/bundle:25:in `load'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/bin/bundle:25:in `<main>'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/bin/ruby_executable_hooks:22:in `eval'
from /home/ec2-user/.rvm/gems/ruby-3.2.0-preview1/bin/ruby_executable_hooks:22:in `<main>'
Ruby 3.2.0 has removed some deprecated methods (taint/trust/untaint/untrust) ,ref: https://bugs.ruby-lang.org/issues/16131 . Bundler version 1.17.3 has that method in shared_helpers.rb . Try updating bundler to 2.4.1 .
Please check before installed Gemfile.lock
you should remove Gemfile.lock before. ( cause, lock file is depends on old version ruby )

Rails capistrano deploy issue, Malformed version number string Capistrano

I'm not very familiar with ruby. I'm trying to deploy existing project to the staging server.
Project uses followings,
ruby 1.8.7
rails 2.3.5
rake 0.8.7
capistrano 2.5.13
capistrano-ext 1.2.1
When I run “cap staging deploy” in my project root, it fails with Malformed version number string Capistrano::Version (ArgumentError)
following is the console output,
/Users/sajithk/.rvm/rubies/ruby-1.8.7-head/lib/ruby/site_ruby/1.8/rubygems/version.rb:187:in `initialize': Malformed version number string Capistrano::Version (ArgumentError)
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head#global/gems/bundler-1.9.1/lib/bundler/capistrano.rb:8:in `new'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head#global/gems/bundler-1.9.1/lib/bundler/capistrano.rb:8
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/configuration/loading.rb:152:in `require'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/configuration/loading.rb:152:in `require'
from ./config/deploy.rb:1:in `load'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/configuration/loading.rb:172:in `load_from_file'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/configuration/loading.rb:89:in `load'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/configuration/loading.rb:86:in `load'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/configuration/loading.rb:86:in `each'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/configuration/loading.rb:86:in `load'
from Capfile:4:in `load'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/configuration/loading.rb:172:in `load_from_file'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/configuration/loading.rb:89:in `load'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/configuration/loading.rb:86:in `load'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/configuration/loading.rb:86:in `each'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/configuration/loading.rb:86:in `load'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/cli/execute.rb:64:in `load_recipes'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/cli/execute.rb:64:in `each'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/cli/execute.rb:64:in `load_recipes'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/cli/execute.rb:30:in `execute!'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/lib/capistrano/cli/execute.rb:14:in `execute'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/gems/capistrano-2.5.13/bin/cap:4
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/bin/cap:19:in `load'
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/bin/cap:19
from /Users/sajithk/.rvm/gems/ruby-1.8.7-head/bin/ruby_executable_hooks:15
I found the issue by myself. This might help someone else who came across same issue in the future.
The issue was with the bundler. I have used the latest version of bundler. Since this is a older project, I seems the bundler is not compatible with them. I downgrade the bundler to 1.0.10. everything works ok now.
Commands used,
rvm #global do gem uninstall bundler
gem install bundler -v ‘1.0.10'
Thanks

Testing older Rails app: circular argument reference warning, cannot load test/unit/assertions

CentOS-6.6
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux-gnu]
Bundler version 1.7.11
I am attempting to patch a older RoR application that was upgraded to 4.0.1 last year. When I run bundle exec cucumber before making any changes I now get this sort of error:
bundle exec cucumber
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/values/time_zone.rb:282: warning: circular argument reference - now
cannot load such file -- test/unit/assertions (LoadError)
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `block in require'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:214:in `load_dependency'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/features/support/local_env.rb:5:in `<top (required)>'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in `load'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in `block in load'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:214:in `load_dependency'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in `load'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/cucumber-1.3.19/lib/cucumber/rb_support/rb_language.rb:95:in `load_code_file'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/cucumber-1.3.19/lib/cucumber/runtime/support_code.rb:180:in `load_file'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/cucumber-1.3.19/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/cucumber-1.3.19/lib/cucumber/runtime/support_code.rb:82:in `each'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/cucumber-1.3.19/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/cucumber-1.3.19/lib/cucumber/runtime.rb:184:in `load_step_definitions'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/cucumber-1.3.19/lib/cucumber/runtime.rb:42:in `run!'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/cucumber-1.3.19/lib/cucumber/cli/main.rb:47:in `execute!'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/gems/cucumber-1.3.19/bin/cucumber:13:in `<top (required)>'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/bin/cucumber:23:in `load'
/home/byrnejb/Projects/Software/theHeart/code/hll_th_forex_rss/libexec/bundler/lib/ruby/2.2.0/bin/cucumber:23:in `<main>'
warning: circular argument reference - xxxx was limited to Cucumber, which formerly was at 1.3.10. So I updated cucumber to 1.3.19. Now I am getting the error in active support. Has anyone else seen this.
I had a problem with Minitest preventing this project from advancing to RoR-4.1 back last spring. I do not know if this is pertinent or not but I include it for completeness.
In any case, who puts testing dependencies into distributed runtime code? Why is activesupport complaining about 'test/unit/assertions'?
Try upgrading from Rails 4.0.1 to 4.0.13
If that doesn't work, try using Ruby 2.1.5 to see if you get the same error message. I bet some gem you're using is running into this issue with Ruby 2.2. Example 1, Example 2. Example 3 from Rails.
The long term solution is to use Ruby 2.2 compatible gems, but by switching to 2.1.5 temporarily, you may be able to solve the problem in the short term and narrow down the specific gem versions that are causing the error.
i just add gem 'test-unit' in Gemfile and run 'bundle install' again. It is solved to me.

Cannot Install Intercom.io gem Ubuntu 12.04 LTS

I'm trying to install intercom.io into my rails app, however I get this when generating the config file:
/var/lib/gems/1.8/gems/intercom-rails-0.2.14/lib/intercom-rails/config.rb:13:in `send': undefined method `define_singleton_method' for IntercomRails::Config:Class (NoMethodError)
from /var/lib/gems/1.8/gems/intercom-rails-0.2.14/lib/intercom-rails/config.rb:13:in `config_reader'
from /var/lib/gems/1.8/gems/intercom-rails-0.2.14/lib/intercom-rails/config.rb:8:in `config_accessor'
from /var/lib/gems/1.8/gems/intercom-rails-0.2.14/lib/intercom-rails/config.rb:74
from /var/lib/gems/1.8/gems/intercom-rails-0.2.14/lib/intercom-rails.rb:9:in `require'
from /var/lib/gems/1.8/gems/intercom-rails-0.2.14/lib/intercom-rails.rb:9
from /var/lib/gems/1.8/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
from /var/lib/gems/1.8/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
from /var/lib/gems/1.8/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
from /var/lib/gems/1.8/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `require'
from /var/lib/gems/1.8/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
from /var/lib/gems/1.8/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
from /var/lib/gems/1.8/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
from /home/ian/SB/config/application.rb:7
from /var/lib/gems/1.8/gems/railties-3.2.11/lib/rails/commands.rb:24:in `require'
from /var/lib/gems/1.8/gems/railties-3.2.11/lib/rails/commands.rb:24
from script/rails:6:in `require'
from script/rails:6
It looks like you're on ruby 1.8, and our gem currently uses a ruby 1.9 feature Object#define_singleton_method
We've created an issue on the intercom/intercom-rails github repo to track fixing this. I'll let you know when there's a new version.
If possible, it's recommended to run rails 3+ on ruby >= 1.9.3 (which for us at least mean't installing from source).
Thanks for bringing this to our attention.

problem installing webrick / mogrel or any other server for Rails 3

I have tried various installation methods for deploying a WEBrick and mongrel from the terminal. When I enter the rails server command I get the following:
Toran1$ rails server
/Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2.rb:8:in `require': dlopen(/Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2.rb:8:in `<top (required)>'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:68:in `require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:66:in `each'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:66:in `block in require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:55:in `each'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:55:in `require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler.rb:120:in `require'
from /Users/Toran1/Sites/simple_cms/config/application.rb:7:in `<top (required)>'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/commands.rb:28:in `block in <top (required)>'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have installed the gem both locally and at the root level, and I also have navigated to the application folder before issuing the command. Any help would be appreciated!
Webrick will install automatically if you install rails in a correct manner.
Try this link
Here
And if you don't want to install rails again, try to install server using gem command
Dont forget to include the gems in Gemfile and to run "bundle install"
If you are using Rails < 3.1 you need to use version ~> 0.2.7 of the mysql2 gem
Checkout the documentation and search for active record: https://github.com/brianmario/mysql2
I'm not sure if that will help solve this problem directly, but it may solve others that you may encounter.
Just update your bundler, maybe of any-one of the older gem is conflicting with latest one, this type of issues arises.
gem install bundler
and then bundler install
If you find again error, then delete GEM.lock file, then run
bundler install
This may resolve the issue.

Resources