Trying to get Rails working with Sybase ASE

331 views
Skip to first unread message

Rolf Pedersen

unread,
Apr 28, 2010, 9:06:26 AM4/28/10
to ruby-on-rails-s...@googlegroups.com

Hi

I'm trying to use the activerecord-sybase-adapter to be able to use ASE with my rails applications.
But, I am struggling...

I followed (most of) the steps on this informative page:
http://trevoke.net/blog/2009/09/11/connecting-to-sybase-with-rails-on-windows-xp/

Initially I had Rails 2.3.5 installed.
I copied the "Ruby Sybase files" as instructed and the Sybase dll files as well, and I installed activerecord-sybase-adapter (1.0.0.9250).
The Sybase environment I already have on my office computer, so it should be allright.
I don't have the mentioned JDBC_HOME setting or the classpath setting, but I'm using Open Client, so should there be any need for the JDBC settings?

Ok, things looked promising, and I started creating a test rails app.

rails testapp

I then edited the database.yml to fit Sybase ASE
development:
  adapter: sybase
  database: testdb
  username: username
  password: password
  host: sauron

The host, sauron, is defined in the sql.ini file.

Running rake db:create tells me that the database testdb already exists. (true)
ruby script\generate scaffold person first_name:string last_name:string     WORKS OK
rake db:migrate --trace    FAILS!
(in C:/work/ror/testapp)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
undefined method `select_rows' for #<ActiveRecord::ConnectionAdapters::SybaseAdapter:0x97d8be8>
c:/prg/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:27:in `select_values'
c:/prg/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:416:in `get_all_versions'
c:/prg/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:532:in `migrated'
c:/prg/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:441:in `current_version'
c:/prg/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:458:in `migrate'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:115:in `detect'
c:/prg/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:458:in `each'
c:/prg/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:458:in `detect'
c:/prg/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:458:in `migrate'
c:/prg/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:400:in `up'
c:/prg/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:383:in `migrate'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:116
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
c:/prg/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
c:/prg/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
c:/prg/ruby/bin/rake:19:in `load'
c:/prg/ruby/bin/rake:19



so... looks like something's missing here. In mysql_adapter.rb there is a select_row function, but not in the sybase_adapter.rb.

I tried downgrading Rails to 2.1.0 because I read somewhere that the activerecord-sybase-adapter perhaps was not working for the latest Rails releases, but got only a slightly different error message:
rake aborted!
select_rows is an abstract method
c:/prg/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/database_statements.rb:34:in `select_rows'
...

Anyone has an idea?

Best regards,
Rolf

--
You received this message because you are subscribed to the Google Groups "Ruby On Rails Sybase Developers" group.
To post to this group, send email to ruby-on-rails-s...@googlegroups.com.
To unsubscribe from this group, send email to ruby-on-rails-sybase-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ruby-on-rails-sybase-developers?hl=en.

Anthony Kelly

unread,
Apr 28, 2010, 9:48:30 AM4/28/10
to Ruby On Rails Sybase Developers, Mike Perz
Perhaps Mike can help you with this one. By the way, have you tried
using iSQL to connect:
http://isql.sourceforge.net/

Thanks,
Anthony M Kelly
Micropact

On Apr 28, 9:06 am, Rolf Pedersen <rolf...@gmail.com> wrote:
> Hi
>
> I'm trying to use the activerecord-sybase-adapter to be able to use ASE with
> my rails applications.
> But, I am struggling...
>
> I followed (most of) the steps on this informative page:http://trevoke.net/blog/2009/09/11/connecting-to-sybase-with-rails-on...

Rolf Pedersen

unread,
Apr 28, 2010, 11:17:17 AM4/28/10
to ruby-on-rails-s...@googlegroups.com
Hi Anthony

I'm not sure where isql fits in this picture... It's a separate program... I'm looking for a database connection adapter for my Rails app... And I thought this activerecord-sybase-adapter gem was the solution.
It just seems like there is something in the Ruby code that does not fit together, perhaps because of mismatched versions.

So I'm basically trying to find out if someone else has this setup running, and if so, I'd like to know the versions of Rails, Ruby, Gem and activerecord-sybase-adapter they are using, and if they had to modify something in the adapter to make it work.

Best regards,
Rolf

Mike Perz

unread,
Apr 28, 2010, 11:50:02 AM4/28/10
to ruby-on-rails-s...@googlegroups.com
Try adding the below code between lines 178 and 179 of sybase_adapter.rb:

# Returns an array of arrays containing the field values.
# Order is the same as that returned by #columns.
def select_rows(sql, name = nil)
result = select(sql, name)
result.map{ |v| v.values}
end

Anthony Kelly

unread,
Apr 28, 2010, 11:51:00 AM4/28/10
to ruby-on-rails-s...@googlegroups.com
It's a tool for double checking your database.yml

Rolf Pedersen

unread,
Apr 28, 2010, 1:56:30 PM4/28/10
to ruby-on-rails-s...@googlegroups.com
Yes, that did the trick.
Thanks, Mike!

Do you know if this adapter is maintained somewhere, or is it just "floating around out there" on mailing lists etc.?
I installed it with "gem install activerecord-sybase-adapter -s http://gems.rubyonrails.org", but it seems strange to me that such a showstopper has not been fixed...

Would perhaps the activerecord-odbc-adapter or the activerecord-jdbc-adapter be a better choice for use with Sybase ASE, if they are better maintained?

Best regards,
Rolf

PS: Thanks again :o)

Mike Perz

unread,
Apr 28, 2010, 3:15:30 PM4/28/10
to ruby-on-rails-s...@googlegroups.com
Yes, I found the solution "floating around out there". I just did a
quick search, but didn't find it again immediately, so I gave up. I'm
not using Sybase at my new job, so I'm no longer following it.

Anthony Kelly

unread,
Apr 28, 2010, 3:22:15 PM4/28/10
to Ruby On Rails Sybase Developers
I own the Sybase gem. (At least last I checked...) I don't maintain it
sadly, but I haven't found a volunteer. Do you want to maintain it? If
not then I don't recommend it. In Open Source nothing happens until
someone like you comes along... But feel free to use jruby if you need
Sybase :)

Thanks
AMK

On Apr 28, 1:56 pm, Rolf Pedersen <rolf...@gmail.com> wrote:
> Yes, that did the trick.
> Thanks, Mike!
>
> Do you know if this adapter is maintained somewhere, or is it just "floating
> around out there" on mailing lists etc.?
> I installed it with "gem install activerecord-sybase-adapter -shttp://gems.rubyonrails.org", but it seems strange to me that such a
> showstopper has not been fixed...
>
> Would perhaps the activerecord-odbc-adapter or the activerecord-jdbc-adapter
> be a better choice for use with Sybase ASE, if they are better maintained?
>
> Best regards,
> Rolf
>
> PS: Thanks again :o)
>
>
>
> On Wed, Apr 28, 2010 at 5:50 PM, Mike Perz <mike.p...@gmail.com> wrote:
> > Try adding the below code between lines 178 and 179 of sybase_adapter.rb:
>
> >        # Returns an array of arrays containing the field values.
> >        # Order is the same as that returned by #columns.
> >        def select_rows(sql, name = nil)
> >          result = select(sql, name)
> >          result.map{ |v| v.values}
> >        end
>
> > On Wed, Apr 28, 2010 at 9:06 AM, Rolf Pedersen <rolf...@gmail.com> wrote:
>
> > > Hi
>
> > > I'm trying to use the activerecord-sybase-adapter to be able to use ASE
> > with
> > > my rails applications.
> > > But, I am struggling...
>
> > > I followed (most of) the steps on this informative page:
>
> >http://trevoke.net/blog/2009/09/11/connecting-to-sybase-with-rails-on...
> > > ruby-on-rails-sybase-...@googlegroups.com<ruby-on-rails-sybase-developers%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/ruby-on-rails-sybase-developers?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Ruby On Rails Sybase Developers" group.
> > To post to this group, send email to
> > ruby-on-rails-s...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > ruby-on-rails-sybase-...@googlegroups.com<ruby-on-rails-sybase-developers%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/ruby-on-rails-sybase-developers?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby On Rails Sybase Developers" group.
> To post to this group, send email to ruby-on-rails-s...@googlegroups.com.
> To unsubscribe from this group, send email to ruby-on-rails-sybase-...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/ruby-on-rails-sybase-developers?hl=en.

Rolf Pedersen

unread,
Apr 28, 2010, 3:45:17 PM4/28/10
to ruby-on-rails-s...@googlegroups.com
Hi Anthony

Thanks for the info.
So, are you saying that you recommend against using this adapter at all?
In that case, do you know what other options I have?
Do you know if it is possible to use the activerecord-odbc or -jdbc adapters instead, and is one of those a better choice when using standard Ruby?
And how would using JRuby improve the situation in any way?
(I'm quite new to Ruby/Rails so I tend to ask a lot... :o) )

Best regards,
Rolf

Kuide

unread,
Mar 12, 2015, 3:22:17 AM3/12/15
to ruby-on-rails-s...@googlegroups.com
I realise this is a really old post, but I'll answer anyway.

With JRuby you can use ActiveRecord JDBC adapter, which supports Sybase

With that adapter, you use regular Sybase JDBC drivers.

With regards,
Timo Kuisma
Reply all
Reply to author
Forward
0 new messages