Active-sqlserver-adapter with Rails 5 application. - ruby-on-rails

I am trying to set up a new application with rails 5. I have a half dozen applications working fine with rails 4.x.
When I try to do a bundle install, I get an error that starts with
Error:[rake --tasks] DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from <top (required)> at C:/Users/cmendla/RubymineProjects/user_message_console/config/application.rb:7)
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from <top (required)> at C:/Users/cmendla/RubymineProjects/user_message_console/config/application.rb:7)
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'activerecord-sqlserver-adapter'.
Gem Load Error is: undefined method `add_order!' for class `Class'
Backtrace for gem load error is:
If I do a bundle show activerecord I get
C:\Users\cmendla\RubymineProjects\user_message_console>bundle show activerecord
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-5.0.0.1
I've tried both a plain gem and a gem with different versions
gem 'tiny_tds'
# gem 'activerecord-sqlserver-adapter', '~> 5.0.0'
gem 'activerecord-sqlserver-adapter'
A bundle install shows an error code of 0
Using activerecord-sqlserver-adapter 2.3.8
(this is a partial list ).....
Using sprockets-rails 3.2.0
Using coffee-rails 4.2.1
Using jquery-rails 4.2.1
Using web-console 3.4.0
Using rails 5.0.0.1
Using sass-rails 5.0.6
Bundle complete! 14 Gemfile dependencies, 58 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Process finished with exit code 0
But then I get the error that I posted above . There server I am using is server 2012
There is some info at https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/rails5 but it doesn't seem clear as to if I am loading the right gem version as that document references gem 'activerecord-sqlserver-adapter', '~> 4.2.0'
If anyone knows of compatibility issues between rails 5 and the ActiveRecord SQL Server Adapter, I can stay with rails 4.x for a bit. Otherwise, I'd like to try to get this working.

I had this problem recently. I solved it by adding the following to the gemfile:
gem 'activerecord-sqlserver-adapter', :github => 'rails-sqlserver/activerecord-sqlserver-adapter', :branch => 'master'

Related

Rails 3.0 - can't load ruby-oci8 with Bundler

Rails n00b here - need some assistance. I am trying to port a Rails3 app from Linux to Windows. My Gemfile looks as follows:
source 'http://rubygems.org'
gem 'rails', '3.0.0'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
gem 'ruby-oci8', '1.0.6'
I do not have an Oracle client on this Windows machine, so I will not be able to natively compile a ruby-oci8 gem.
I have commented out the 'ruby-oci8' line in my Gemfile and I installed the gem manually from here: http://rubygems.org/downloads/ruby-oci8-1.0.6-x86-mswin32-60.gem. I have also copied the necessary DLLs into ruby\bin.
I have verified that it works:
ruby -rubygems -e "require 'oci8'; OCI8.new('user','password','pasdev:2700/gen11dvu').exec('select * from ARCS_USER_LO
GON') do |r| puts r.join(','); end"
This returns lots of data from my db, so I know it works.
However, if I try to require 'oci8' from a rails console (or from the running app), I get the following:
LoadError: no such file to load -- oci8
I presume this happens b/c Rails only loads the gems specified in the Gemfile, but I cannot figure out how to specify it! I already have the gem I need installed:
C:\javadev\ashbtw3>gem list
*** LOCAL GEMS ***
activerecord (3.0.0)
bundler (1.0.21, 1.0.0)
rails (3.0.0)
rake (0.8.7)
ruby-oci8 (1.0.6 x86-mswin32-60)
...etc...
Yet if I uncomment this line in the Gemfile:
gem 'ruby-oci8', '1.0.6'
bundler tries to download and compile another 1.0.6, which of course fails. I have also tried all of these variations unsuccessfully:
gem 'ruby-oci8', '1.0.6', :platforms => :mingw
gem 'ruby-oci8', '1.0.6-x86-mswin32-60', :platforms => :mingw32
gem 'ruby-oci8-1.0.6-x86-mswin32-60'
gem 'ruby-oci8', '1.0.6-x86-mswin32-60'
Why is bundler trying to install a gem that I already have? How do I properly specify the version and platform to make Bundler see that this gem is already installed, and just include it in Gemfile.lock? Is there some other solution here that I can use w/o installing an Oracle client?
EDIT 1:
As per Kyle's suggestion, I tried the following:
gem 'ruby-oci8', :path => 'C:/Ruby187/lib/ruby/gems/1.8/gems/ruby-oci8-1.0.6-x86-mswin32-60
This made Bundler run successfully!
Using ruby-oci8 (1.0.6) from source at C:/Ruby187/lib/ruby/gems/1.8/gems/ruby-oci8-1.0.6-x86-mswin32-60
However, trying to require 'oci8' from the Rails console now gives me this:
C:\javadev\ashbtw3>ruby script\rails console
Loading development environment (Rails 3.0.0)
irb(main):001:0> require 'oci8'
LoadError: no such file to load -- oci8lib
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `load_dependency'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:591:in `new_constants_in'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `load_dependency'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/ruby-oci8-1.0.6-x86-mswin32-60/lib/oci8.rb:20
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
The file it's missing is in under ext/oci8 in the installed gem directory, yet it does not see it.
Is there something additional I can do?
Have you tried specifying the :path ?
gem 'ruby-oci8', :path => '/path/to/ruby-oci8-1.0.6-x86-mswin32-60'

Cucumber is not working with rails 2.3.14 & ruby 1.8.7/ree

My enviorenment:
**Rails - 2.3.14
Ruby - ree/ruby 1.8.7**
I am trying to use cucumber for the first time. I followed => http://railscasts.com/episodes/155-beginning-with-cucumber for my existing project.
I have executed the **bold** commnads but it is giving the below mentioned error though I have rspec-core,rack-test & i18n latest version in my system:
==============================================================================
**rvmsudo rake gems:unpack RAILS_ENV=test**
[sudo] password for ilfs:
(in /home/ilfs/work/ces)
Please install RDoc 2.4.2+ to generate documentation.
DEPRECATION WARNING: Rake tasks in vendor/plugins/TBD_ prawnto/tasks, vendor/plugins/jrails/tasks, and vendor/plugins/online_help/tasks are deprecated. Use lib/tasks instead. (called from /home/ilfs/.rvm/gems/ree-1.8.7-2012.02#ces/gems/rails-2.3.14/lib/tasks/rails.rb:10)
gem install rspec --version ">= 1.2.2"
ERROR: Error installing rspec:
rspec requires rspec-core (~> 2.11.0)
gem install rspec-rails --version ">= 1.2.2"
ERROR: Error installing rspec-rails:
activesupport requires i18n (~> 0.6)
gem install webrat --version ">= 0.4.3"
ERROR: Error installing webrat:
webrat requires rack-test (>= 0.5.3)
rake aborted!
undefined method `version' for nil:NilClass
(See full trace by running task with --trace)
============================================================================
ilfs#ilfs:~/work/ces$ **rvmsudo rake gems:unpack:dependencies RAILS_ENV=test**
(in /home/ilfs/work/ces)
Please install RDoc 2.4.2+ to generate documentation.
DEPRECATION WARNING: Rake tasks in vendor/plugins/TBD_ prawnto/tasks, vendor/plugins/jrails/tasks, and vendor/plugins/online_help/tasks are deprecated. Use lib/tasks instead. (called from /home/ilfs/.rvm/gems/ree-1.8.7-2012.02#ces/gems/rails-2.3.14/lib/tasks/rails.rb:10)
gem install rspec --version ">= 1.2.2"
ERROR: Error installing rspec:
rspec requires rspec-core (~> 2.11.0)
gem install rspec-rails --version ">= 1.2.2"
ERROR: Error installing rspec-rails:
activesupport requires i18n (~> 0.6)
gem install webrat --version ">= 0.4.3"
ERROR: Error installing webrat:
webrat requires rack-test (>= 0.5.3)
rake aborted!
undefined method `version' for nil:NilClass
(See full trace by running task with --trace)
==================================================================================
This is first time I am trying to use cucumber, have no idea about it except rails cast video's concept. As I my system does not yet configured so I am not able to test anything.
Expecting help -
Thanks in advance
Sumanta
I solved this issue - at first I was adding gems in enviorement/tests.rb but after adding those gems in gemfile - problem get solved.
this is the step-
in gemfile
group :development, :test do
#gem "rspec-rails", '>=1.3.2'
gem 'rspec', '>=1.3.2'
gem "capybara", "0.3.9"
gem "cucumber", ">=0.2.2"
gem "cucumber-rails", "0.3.2"
gem 'database_cleaner'
gem 'webrat', ">=0.4.3"
end
from project folder console/terminal run this command => ruby script/generate cucumber
At a glance I would say that your are having dependency issues. Rails 2 is pretty old, and those gems you are trying to install have moved quite far ahead of where Rails 2 is.
So I would avoid using the ">=" specification in the Gem requirement.
Since you're using a Railscasts as a learning tool, I would make the Gem versions "=".
So you can at least guarantee that the versions are the same.
Using ">=" for legacy project is pretty dangerous as Ruby gems are fast moving targets.
So for every legacy app, there comes a day when you have to lock versions.

Error stating that "bcrypt-ruby is not part of the bundle", how can I add bcrypt-ruby to Gemfile?

When I add has_secure_password to the model (inherited from ActiveRecord::Base), error stating that "bcrypt-ruby is not part of the bundle" occurs.
Here the log is:
Started GET "/users" for 127.0.0.1 at 2012-02-19 16:37:12 +0900
Gem::LoadError (bcrypt-ruby is not part of the bundle. Add it to Gemfile.):
app/models/user.rb:3:in `<class:User>'
app/models/user.rb:1:in `<top (required)>'
app/controllers/users_controller.rb:1:in `<top (required)>'
I installed bcrypt-ruby by
$ gem install bcrypt-ruby
Building native extensions. This could take a while...
1 gem installed
Installing YARD (yri) index for bcrypt-ruby-3.0.1...
Installing RDoc documentation for bcrypt-ruby-3.0.1...
but was no avail.
I tried
$ bundle exec rails server
but was no help.
If I comment out the line "has_secure_password", this error does not come out.
How can I solve this problem?
I already had gem 'bcrypt-ruby', '~> 3.0.0' in Gemfile, and had already ran the command bundle, and yet I still got that message. The problem was that I forgot to restart the server:
touch tmp/restart.txt
As the message says you need to add bcrypt-ruby to your Gemfile (at the root of the project).
Adding
gem "bcrypt-ruby"
and then running bundle install should do the trick (this would fetch the gem if you hadn't already installed it).
You can specify specific versions to, eg
gem "bcrypt-ruby", "~> 3.0.1"
will get you the latest version that is >= to 3.0.1 but less than 3.1. You might do this if 3.0.1 has a bug fix you depend on and you're happy to get more bug fixes but you don't want major changes. There's loads more info on the bundler website.
In your Gemfile add a line
gem 'bcrypt-ruby'
and then from the command line
bundle install
Something that came up for me that is not addressed here yet. I got this error after going to a new system on which I installed Ruby 2.0.x.
It turns out that even if I was using the new bcrypt 3.1.7 it didn't work for me until I ALSO had bcrypt-ruby 3.0.1 in the gemfile. I resisted that when I should have just taken the error at it's word.
gems:
bcrypt (3.1.7 ruby x86-mingw32)
bcrypt-ruby (3.0.1 x86-mingw32, 3.0.0)
gemfile:
gem 'bcrypt-ruby', '~> 3.0.1'
gem 'bcrypt', '~> 3.1.7'
Before adding both I tried all sorts of single version combinations.
Restart the server and reinstall bundle in correct order, that is:
bundle install, bundle update, bundle install
and then server restart.
If you already put the gem in the gem file and bundle installed and you are still getting an error then restart your server.

heroku - can't activate test-unit (= 1.2.3, runtime), already activated test-unit-2.3.1. Make sure all dependencies are added to Gemfile

I keep getting this error on heroku....here is my gemfile...what do i do
source 'http://rubygems.org'
gem 'rails', '2.3.8'
gem 'will_paginate', '2.3.12'
gem 'googlecharts'
# gem 'faker'
gem 'httparty'
gem 'bandsintown'
gem 'itunes-search-api','0.1.0', :path => 'vendor/gems/itunes-search-api-0.1.0'
gem 'i18n', '0.4.2'
gem "giggly", "~> 0.1.2"
gem "ruby-paypal",'0.0.5', :path => 'vendor/gems/ruby-paypal-0.0.5'
group :production do
gem 'test-unit', "2.3.1"
gem 'pg'
end
group :development, :test do
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
end
I tried taking it gem 'test-unit', "2.3.1" out and even leaving it without a specific version and I got this error...
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
rake aborted
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
rake aborted!
can't activate test-unit (= 1.2.3, runtime), already activated test-unit-2.3.1. Make sure all dependencies are added to Gemfile.
/usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/shared_helpers.rb:108:in `block in cripple_rubygems'
Now I am getting this error
/app/lib/tasks/rspec.rake:1:in `<top (required)>'
test-unit is not part of the bundle. Add it to Gemfile.
/usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/shared_helpers.rb:102:in `block in cripple_rubygems'
/app/lib/tasks/rspec.rake:1:in `<top (required)>'
I am so confused...on what to do next
To sum up:
no need of test-unit in production
remove the rspec rake task since you don't use rspec
For me, this error:
/app/lib/tasks/rspec.rake:1:in `<top (required)>'
test-unit is not part of the bundle. Add it to Gemfile.
started unexpectedly when I went to do some maintenance work on an old project. This was triggered by this line in the rspec rake task:
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
In returning to this application, the default Ruby version was upgraded to 1.9. Using RVM to set this back to 1.8 (in my case under Jruby) eliminated this message and got me back going as before without the message.
Charles
An error like this can occur if your code loads some gems before Bundler is run and it happens to load a different version than is specified in Gemfile and Gemfile.lock. When Bundler is run later, it will detect that the wrong version of a gem has been loaded and raise this error. The solution is to make sure the Bundler.setup runs before any other gems are loaded. There are instructions on how to do this in Rails 2.3 on the bundler website, which you should follow:
http://gembundler.com/rails23.html

Can't start Rails 3 app

I have just configured dependencies for a simple Rails application using Gemfile, but I'm not able to start it anymore.
Here is the error message I get:
/Library/Ruby/Site/1.8/rubygems.rb:274:in `activate': can't activate rails (= 2.3.5, runtime) for [], already activated rails-3.0.4 for [] (Gem::LoadError)
from /Library/Ruby/Site/1.8/rubygems.rb:216:in `try_activate'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
...
The Gemfile is configured as follows
source :rubygems
gem 'rails', '3.0.4'
#gem 'rails', '2.3.5'
gem 'fastercsv', '1.5.4'
gem 'comma', '0.4.1'
and my environment.rb contains the following line
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '3.0.4' unless defined? RAILS_GEM_VERSION
Note that if I change that variable to 2.3.5, the server starts.
Any idea about what is causing the issue?
If you want to change an existing gemfile run: bundle update. Bundle install is only used for the initial setup. And by the way we are at 3.0.5 now. I am also wondering was this a rails 2 application? Did you simply swap out the gem version number and expect it to then become a rails 3 app? The environment.rb file in a rails 3 application does not show the rails gem version.

Resources