Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8660097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:10:18+00:00 2026-06-12T16:10:18+00:00

I am trying to connect to an existing Sybase db using Rails and populate

  • 0

I am trying to connect to an existing Sybase db using Rails and populate a few selection lists. Here’s what I have done so far:
1. Installed and configured FreeTDS
2. Installed TinyTDS gem

if I execute command tsql -S serverName -U userName, I’m able to query the data. I have my config/database.yml configured as such:

development:  
  adapter: sybase  
  host: <sybase_host>  
  port: <port_no>  
  username: <user>  
  password: <password>  
  database: <db>

I then tried generating a model via rails generate model sybase_db --skip-migration and editing the created app/models/sybase_db.rb file as follows:

class SybaseDb < ActiveRecord::Base  
  set_table_name "my_sybase_table"  
end

When I try to run SybaseDb.new command in rails console, it doesn’t seem to work. I’m pretty new to Rails so what am I doing wrong?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:10:19+00:00Added an answer on June 12, 2026 at 4:10 pm

    Everything looks right up to the part where you generate a model called sybase_db. A model in Rails is typically linked to a specific table in a database, not the whole database. Rails uses naming conventions to simplify the linking of tables and columns to models and attributes.

    For example, if you have a model User with attributes name and email that is linked to a table in your database called users and having columns name and email then all sorts of wonderful Rails magic just works. You could start the rails console and execute User.all to produce a collection of all users in the database. Or you might do something like

    > u = User.find_by_email 'joe@example.com'
    => #<User id: 123, email: "joe@example.com", name: "Joe"...>
    > u.name
    => "Joe"
    

    If you have an existing database, however, chances are you’re going to have to explain in more detail to Rails how to map the names in Sybase to those in your Rails system. You have one case of this in set_table_name — if your Sybase table was named t_user with a primary key of user_id but it had columns name and email then you could create a Rails model like

    class User < ActiveRecord::Base
      set_table_name "t_user"
      set_primary_key "user_id"
    end
    

    Here’s a discussion of this topic on Quora with a couple good links that you might use to go further.

    Depending on how extensive your existing system is, you may find that all of the magic of Rails goes away. Rails helps us avoid all of this mapping this to that, and follows strong naming conventions to give us all sorts of wonderful coolness. If your existing system has strong and predictable naming conventions, and isn’t terribly far off from Rails’ way, you might be able to use Rails successfully.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have this pre-existing database that I'm trying to connect to using Django
I am trying to accomplish the following tasks: Connect to an existing server using
I am trying to connect to a MySQL Server using JDBC tool in java
I'm trying to connect to a FTP using Apaches FTPSClient but I keep getting
I'm trying to connect to an existing Windows Service that exposes several WCF endpoints.
I am trying to write an Android app to connect to an existing web
I'm trying to connect to an existing database (non-SQLEXPRESS) but everytime I try to
I'm trying to connect Tab Bar Controller to existing part of my app, but
I am trying to connect to the existing db in oracle with fluentmapping .
We have been using weborb for .net on an existing application for some time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.