How map mongodb on ruby and rails - mongodb

I am practice on ruby on rails 4 and using mongodb database,I am trying to work follow this site to connect database : http://mongoid.org/en/mongoid/docs/documents.html
However, when I worked this step this occur error:
rails g mongoid:config
error:
Bundler could not find compatible versions for gem "activemodel":
In snapshot (Gemfile.lock):
activemodel (4.1.1)
In Gemfile:
mongoid (~> 3.1.6) x86-mingw32 depends on
activemodel (~> 3.2) x86-mingw32
Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
I am also try the command bundel update but it has that error:
sorry I am new bie on ruby and rails and mongodb, so I hope there is any easy guide to follow.
thankyou

Try skipping ActiveRecord when creating your app.
rails new my_app -O
I had this problem using the following:
gem 'rails', '4.1.1'
gem 'mongoid', '~> 4.0.0'
Skipping ActiveRecord solved that error.

Related

installing dmsf plugin in redmine

while installing dmsf plugins, I ran the following command:
bundle exec rake redmine:plugins:migrate RAILS_ENV="production"
Its throwing the following error:
rake aborted!
cannot load such file -- dav4rack
Is it due to my wrong setting of the gem file or something else? Can someone give me a clue?
Its problem for nokogiri gem version not support You have to upgrade nokogiri gem or downgrade mention in the gem file

Need help getting rails server to work

So I feel incredibly frustrated. I am doing www.railstutorial.org and they require a very specific version of rails (4.2.2). I have installed it as they wanted. Put in their Gemfile specs on their "hello_app" app they provided. When I run "rails server" I get an error message saying that "byebug" is erroring. I try to install earlier and later versions of bye bug and I get the same error message. Can someone please help me? I feel pretty lost.
The tutorial is at the url below.
https://www.railstutorial.org/book/beginning#code-hello_action
alopex#alopex-TH55-HD:~/workspace/hello_app$ more Gemfile
source 'https://rubygems.org
gem 'rails', '4.2.2'
gem 'sass-rails', '5.0.2'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks', '2.3.0'
gem 'jbuilder', '2.2.3'
gem 'sdoc', '0.4.0', group: :doc
group :development, :test do
gem 'sqlite3', '1.3.9'
gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
end
alopex#alopex-TH55-HD:~/workspace/hello_app$ bundle install
Gem::InstallError: byebug requires Ruby version >= 2.0.0.
An error occurred while installing byebug (3.4.0), and Bundler cannot continue.
Make sure that `gem install byebug -v '3.4.0'` succeeds before bundling.
alopex#alopex-TH55-HD:~/workspace/hello_app$ sudo gem install byebug -v 3.4.0
ERROR: Error installing byebug:
byebug requires Ruby version >= 2.0.0.
I fixed this problem in this way:
Open your application's Gemfile
remove: gem 'byebug'
replace it with: gem 'pry-byebug', platform: [:ruby_20]
It isn't rails issue: byebug requires Ruby version to be 2.0 at least. You can check your Ruby version with ruby -v, I guess it is 1.9.3 in your case. You can use rvm to install actual Ruby version on your system.
Also, you can try to remove byebug from Gemfile and try to run bundle again. Maybe other gems can run with ruby 1.9.3, and you can learn rails without dealing with rvm.

Ruby On Rails gem dependency conflict when install "google-api-client"

I added to Gemfile : gem 'google-api-client', "0.6.4"
1> execute “bundle install”, and got this error:
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "addressable":
In Gemfile:
google-api-client (= 0.6.4) ruby depends on
addressable (>= 2.3.2) ruby
koala (>= 0) ruby depends on
addressable (2.2.8)
2> execute “bundle update koala”, got this error:
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "launchy":
In snapshot (Gemfile.lock):
launchy (2.1.0)
In Gemfile:
google-api-client (= 0.6.4) ruby depends on
launchy (>= 2.1.1) ruby
Running bundle update will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
What is the core issue of this error?
And how can I solve it?
Thank you.
[Update]
When I execute 'bundle update addressable', got this error:
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "launchy":
In snapshot (Gemfile.lock):
launchy (2.1.0)
In Gemfile:
google-api-client (= 0.6.4) ruby depends on
launchy (>= 2.1.1) ruby
Running bundle update will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
The version of koala you are using required addressable-2.2.8, but google-api-client wants addressable-2.3.2 or higher. The latest version of koala does not specify a specific version of addressable, so try updating koala:
bundle update koala

SystemStackError (stack level too deep): error while uploading image in rails

I am working on ROR and providing api to IOS app. In this app an IOS user uploads an image to Rails App. I am working with paperclip gem. This was working fine before I run the bundle update command. Now I am getting this error:
SystemStackError (stack level too deep):
actionpack (3.2.3) lib/action_dispatch/middleware/reloader.rb:70
My Gemfile looks like this:
gem 'rails', '3.2.3'
gem 'bootstrap-sass', '2.0.0'
gem 'bcrypt-ruby', '3.0.1'
gem 'paperclip', '~> 3.0'
gem 'activerecord-import', '>= 0.2.0'
gem 'execjs'
gem 'therubyracer'
IOS developers are using Base64 to encode an image before uploading to Rails App. My Rails app uses this method to decode the photo_data:
def decode_photo_data
data = StringIO.new(Base64.decode64(self.photo_data))
self.photo = data
end
This was all working fine but I don’t know whether it is IOS bug or Rails bug. If it is Rails bug is it related to paperclip or something else. Please help.
Ok I got the solution for this. I find out that this is a paperclip bug. Since I run the bundle update command, it downloaded a new paperclip version paperclip-3.4.1 but before bundle update or bundle install it was using paperclip-3.3.1 so now I updated my Gemfile to this:
gem 'rails', '3.2.3'
gem 'bootstrap-sass', '2.0.0'
gem 'bcrypt-ruby', '3.0.1'
gem 'paperclip', '~> 3.3.1'
And it starts working again in my case. No error now.

Trouble upgrading to rails 2.3.15 with rack 1.1.3

I'm getting the following error when trying to fire up script/console for my rails 2.3.15 app, after upgrading from rails 2.3.5. Does this mean the issue is with bundler 1.2.1 is not compatible with rack 1.1.3? Any help would be appreciated immensely.
usr/lib/ruby/gems/1.8/gems/bundler-1.2.1/lib/bundler/rubygems_integration.rb:157:in gem': can't activate rack (~> 1.0.1), already activated rack-1.1.3. Make sure all dependencies are added to Gemfile. (Gem::LoadError)
from /home/developer/bigpink/vendor/rails/actionpack/lib/action_controller.rb:34
from /home/developer/bigpink/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:inrequire'
from /home/developer/bigpink/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require'
from /home/developer/bigpink/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:innew_constants_in'
from /home/developer/bigpink/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require'
from /home/developer/bigpink/vendor/rails/railties/lib/commands/server.rb:2
from script/server:3:inrequire'
from script/server:3
In my case, problem solved by the following steps:
Deleted the directory $PROJECT_ROOT/vendor/rails
Modified RAILS_GEM_VERSION in config/environment.rb
we used this process to upgrade Rails to 3.2.11 on our Heroku apps (as reported here)
stop – your Ruby on Rails (RoR) server
edit – appropriate line in gem file to read [one of]:
gem ‘rails’, ’3.2.11′
gem ‘rails’, ’3.1.10′
gem ‘rails’, ’3.0.19′
gem ‘rails’, ’2.3.15′
run – gem update
run – bundle update
run - bundle install
test – rspec # or test-driven dev’t framework of choice
launch – rails s
test – # interact with Rails server & explore if all is well
run – git add .
run – git commit -a -m “upgrade Rails server to ver. [x.y.z]“
run - git push # to github or rcs of choice
run - git push heroku # or to deployment server of choice