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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:35:31+00:00 2026-06-04T05:35:31+00:00

Currently in my Sinatra + DataMapper app, I have: require ‘data_mapper’ DataMapper.setup(:default, sqlite3://#{Dir.pwd}/main.db) DataMapper.setup(:comments,

  • 0

Currently in my Sinatra + DataMapper app, I have:

require 'data_mapper'

DataMapper.setup(:default,  "sqlite3://#{Dir.pwd}/main.db")
DataMapper.setup(:comments, "sqlite3://#{Dir.pwd}/comments.db")

class Recording
    include DataMapper::Resource

    # ...

    belongs_to :user
    has n, :comments
end

class User
    include DataMapper::Resource

    # ...

    has n, :recordings
end

class Audience
    include DataMapper::Resource

    # ...
end

# -------- ITS OWN DATABASE --------
class Comment
    include DataMapper::Resource

    #...

    belongs_to :recording
end

I want the Comments class to go separately from the others into comments.db. I was looking around, and I saw something like this (and to which I have formatted to my situation):

# -------- ITS OWN DATABASE --------
repository(:comments) do 
    class Comment
        include DataMapper::Resource

        #...

        belongs_to :recording
    end
end

Would this work out as planned, or is there a proper way to do this?

  • 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-04T05:35:32+00:00Added an answer on June 4, 2026 at 5:35 am

    We override the #default_repository_name method on our models to do this:

    class Comment
      include DataMapper::Resource
    
      def self.default_repository_name
        :comments
      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 simple config.ru file for my Sinatra app. require 'sinatra' require 'app'
I have a Sinatra app that runs inside of EventMachine. Currently, I am taking
I have a problem with DataMapper (I'm using it with Sinatra) I have a
I am using datamapper in a Sinatra application. I currently use the command DataMapper.finalize.auto_upgrade!
I am currently struggling with stubbing out a helper method of my Sinatra app
I'm building a web app in Sinatra and I have a bunch of files
I have a Sinatra app that serves pages as read-only or editable depending on
I have a simple Sinatra app that I am playing with, and for some
I am working with DataMapper and Sinatra to create a simple app. Here's the
I have a small web application that is currently running on Sinatra . It

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.