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 3975072
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:38:30+00:00 2026-05-20T04:38:30+00:00

So, I have Ruby on Rails application. Blank for now. And let me say

  • 0

So, I have Ruby on Rails application. Blank for now. And let me say right from the beginning that most of my experience is from Java, so I might be thinking not the way RoR devs do. 🙂

What I need to do is to create some Data Access Layer, say it will be access users, so let it be
UserDAO.rb which will be basically then using ActiveRecord or directly accessing the database or accessing or some key-value storage or anything else I can think of.

Technically, as we don’t have interfaces in Ruby, I can make UserDAO.rb to “have” the implementation (basically, I am talking about composition), which may be anything we need, say UserDAOActiveRecord.rb or UserDAOMongo.rb or anything else like that. UserDAO.rb will basically call the methods of the implementation and that’s it. Should be easy to switch between implementations.

While it does sound like a possible solution, I am looking forward to hear what are the best practices for this problem in the Ruby world. 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-05-20T04:38:31+00:00Added an answer on May 20, 2026 at 4:38 am

    You will have to look for a Ruby Class other than ActiveRecord (which as pointed out is an Object Relational Mapper, so has no separate data access layer).

    You might want to look at: https://github.com/jeremyevans/sequel

    You could create a class, Person, which contains methods which use an instance of Sequel to talk to the database.

    This untested code demonstrates why this might not be a great idea:

    class Person
      attr_reader :first_name, :last_name
    
      DataSource = Sequel.sqlite('my_app.db')[:people]
    
      def initialize(record)
        @first_name = record.first_name
        @last_name = record.last_name
      end
    
      # Find a record from the database and use it to initialize a new Person object 
      def self.find_by_id(id)
        self.new(Table.where(:id => id))
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Ruby on Rails application that will be a CMS in way
I have a ruby-on-rails application and I'm now wondering why RoR uses Restful Requests:
I have a Ruby on Rails application that has two active environments, Stage and
I have a Ruby on Rails Website that makes HTTP calls to an external
I have a Ruby script in my Rails app that I use to load
I have a simple Rails 3.b1 (Ruby 1.9.1) application running on Sqlite3. I have
I have an Rails application with SayController , hello action and view template say/hello.html.erb
I have a Ruby on Rails application I'm using Ruby 1.9 and Rails 2.3.4
I have a Ruby on Rails (2.3.5) application and an APE (Ajax Push Engine)
Some of the users of our Ruby on Rails app have complained that page

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.