This message in actually about two different (I guess) problems.
First, I'm trying to use the activerecord-sqlserver-adapter gem
version 2.3 but I keep getting this error message telling me it cannot
load the file when I try to run script/server
no such file to load -- activerecord-sqlserver-adapter
My environment.rb looks like this:
config.gem 'dbi', :version => '0.4.1'
config.gem 'dbd-odbc', :version => '0.2.4', :lib => 'dbd/ODBC'
config.gem 'activerecord-sqlserver-adapter', :version => '2.2.22'
My gems env:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.5
- RUBY VERSION: 1.8.6 (2008-08-11 patchlevel 287) [universal-
darwin9.0]
- INSTALLATION DIRECTORY:
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/
Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-9
- GEM PATHS:
-
- /Users/cassiomarques/.gem/ruby/1.8
- /Library/Ruby/Gems/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gemcutter.org", "http://
gems.rubyforge.org/", "http://gems.github.com", "http://
gemcutter.org", "http://gems.github.com"]
- "gemcutter_key" => "31bf192bfd58ad85128672889089158d"
- REMOTE SOURCES:
- http://gemcutter.org
- http://gems.rubyforge.org/
- http://gems.github.com
My script/server script:
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
The interesting thing is that when I change it to use the 2.2.22
version instead of the 2.3, it seems to work and I can access my
database normally.
Another problem I'm having is when searching the database using any
date field, it keeps giving me this error:
undefined method `create' for DBI::Type::Timestamp:Class
For instance, when doing something like this:
def self.find_all_by_date_and_office_code(date, code)
cond = ["CAST(FLOOR( CAST( dateatend AS FLOAT ) ) AS DATETIME) = ?
and id_office = ?", date, code]
find(:all, :conditions => cond)
end
Any ideas?
Thank you very much!
config.gem 'dbi', :version => '0.4.1'
config.gem 'dbd-odbc', :version =>
'0.2.4', :lib => 'dbd/ODBC'
config.gem 'activerecord-sqlserver-adapter', :version =>
'2.3', :lib => 'active_record/connection_adapters/
sqlserver_adapter'
>> ActiveRecord::Base.connection.sqlserver?
=> true
>> ActiveRecord::Base.connection.version
=> "2.3"
I just added the explicit load path and that works. I guess this
should have been there all along, but I have no idea how a change from
2.2.x to 2.3 could have made this blow up. Part of me thinks that
perhaps a rails 2.3.x version would have something to do with the
magic, but I saw nothing in the configuration specification that would
suggest that. Either way, I'll change the docs to reflect this...
after I do the 3.x changes and hopefully as people start to use the
gem bundler (rails3 way) then thisis moot too, but there is the
solution. Sorry I did not find this earlier, still have no idea what
is really happening.
- Ken
--
You received this message because you are subscribed to the Google Groups "Rails SQLServer Adapter" group.
To post to this group, send email to rails-sqlse...@googlegroups.com.
To unsubscribe from this group, send email to rails-sqlserver-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rails-sqlserver-adapter?hl=en.
Ok Ken, thank you for your attention, I'll try to config my environment.rb file like you did :)About the 'undefined method `create' for DBI::Type::Timestamp:Class' error, do you have any ideas
Thank you!
--
You received this message because you are subscribed to the Google Groups "Rails SQLServer Adapter" group.
To post to this group, send email to rails-sqlse...@googlegroups.com.
To unsubscribe from this group, send email to rails-sqlserver-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rails-sqlserver-adapter?hl=en.
To rectify it I just had to recreated the missing the file 'lib/
activerecord-sqlserver-adapter.rb' which existed in the 2.2.x
versions. The file is missing because it is no longer listed in the
gem spec as an included file so does not get packaged in the gem. Once
replaced everything works as normal.
I can also successfully switch versions of the gem with the version
option in config.gem. I have verified this in console and server.
Adam
On Dec 24 2009, 2:07 am, Ken Collins <k...@metaskills.net> wrote:
> Cássio's issue was mainly related to the way he had multiple versions of ruby installed and hence would have a gem installed but that gem env was not visible to a certain ruby install.
>
> Joe, you are right tho and I know totally what your talking about. A while back ago I started organizing all my gems better using these two articles as a guide for best practices:
>
>
> The adapter follows these conventions since a few months ago. Nothing for load path, requires changed between 2.2.22 and 2.3 and some voodoo could be related to what your talking about, but for the live of me I could not see it.
>
> - Ken
>
> On Dec 22, 2009, at 8:41 PM, Joe Rafaniello wrote:
>
> > I'm not sure if you guys already resolved this in IRC but this sounds like the notoriously bad rubygems "auto-add every stupid gem lib dir into the load path and ALWAYS load the newest version of a gem regardless of what the user wants in config.gem."
>
> > From my experience, if you have a gem activerecord-sqlserver-
> > adapter, at versions 2.2.3 and 2.3 installed in either the rubygems standard gem location or vendor/gems and you require rubygems in your code, you will never be able to load the gem 2.2.3 because 2.3 will always be activated via the gem method. You can either uninstall the 2.3 gem, not use rubygems, use bundler, or do a clever hack: (although bundler sounds like a better longer time solution):
> >http://blog.behindlogic.com/2009/08/my-version-of-rubygems.html
>
> > Just my 2 cents.
>
> > Joe
>
> > 2009/12/22 Cássio Marques <cassio...@gmail.com>
> > My environment.rb when trying to use 2.3
>
> > config.gem 'dbi', :version => '0.4.1'
> > config.gem 'dbd-odbc', :version => '0.2.5', :lib => 'dbd/ODBC'
> > config.gem 'activerecord-sqlserver-adapter', :lib => 'active_record/connection_adapters/sqlserver_adapter', :version => '2.2.3'
>
> > $ rubyee script/server -e production
> > => Booting Mongrel
> > => Rails 2.3.5 application starting onhttp://0.0.0.0:3000
> >>>> For more options, visit this group athttp://groups.google.com/group/rails-sqlserver-adapter?hl=en.
>
> >>>> --
> >>>> Cássio Marques
>
> >>>> Blog:http://cassiomarques.wordpress.com
>
> >>>> If you're writing code and you're not testing it, the code is wrong. I don't care if it does the right thing, and people need to understand this. If it works by accident, you're still wrong.
> >>>> Bryan Liles - Ruby Hoedown 2008
>
> >>>> --
>
> >>>> You received this message because you are subscribed to the Google Groups "Rails SQLServer Adapter" group.
> >>>> To post to this group, send email to rails-sqlse...@googlegroups.com.
> >>>> To unsubscribe from this group, send email to rails-sqlserver-a...@googlegroups.com.
> >>>> For more options, visit this group athttp://groups.google.com/group/rails-sqlserver-adapter?hl=en.
>
> >>> --
>
> >>> You received this message because you are subscribed to the Google Groups "Rails SQLServer Adapter" group.
> >>> To post to this group, send email to rails-sqlse...@googlegroups.com.
> >>> To unsubscribe from this group, send email to rails-sqlserver-a...@googlegroups.com.
> >>> For more options, visit this group athttp://groups.google.com/group/rails-sqlserver-adapter?hl=en.
>
> >> --
>
> >> You received this message because you are subscribed to the Google Groups "Rails SQLServer Adapter" group.
> >> To post to this group, send email to rails-sqlse...@googlegroups.com.
> >> To unsubscribe from this group, send email to rails-sqlserver-a...@googlegroups.com.
> >> For more options, visit this group athttp://groups.google.com/group/rails-sqlserver-adapter?hl=en.
>
> >> --
> >> Cássio Marques
>
> >> Blog:http://cassiomarques.wordpress.com
>
> >> If you're writing code and you're not testing it, the code is wrong. I don't care if it does the right thing, and people need to understand this. If it works by accident, you're still wrong.
> >> Bryan Liles - Ruby Hoedown 2008
>
> >> --
>
> >> You received this message because you are subscribed to the Google Groups "Rails SQLServer Adapter" group.
> >> To post to this group, send email to
>
> ...
>
> read more »
- Ken
Any suggestions.
Here's the versions of gems used
activerecord-sqlserver-adapter (2.3.1)
rails (2.3.2)
dbd-odbc (0.2.5)
dbi (0.4.1)
Thanks
nanda
> >>> rails-sqlserver-a...@googlegroups.com<rails-sqlserver-adapter%2Bunsu...@googlegroups.com>
> >> rails-sqlserver-a...@googlegroups.com<rails-sqlserver-adapter%2Bunsu...@googlegroups.com>
> > rails-sqlserver-a...@googlegroups.com<rails-sqlserver-adapter%2Bunsu...@googlegroups.com>