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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:23:58+00:00 2026-06-06T17:23:58+00:00

If I had two tables, users and blocked_users , how would I define the

  • 0

If I had two tables, users and blocked_users, how would I define the relationship from blocked_users to users?

For example,

class User < Sequel::Model

  one_to_many :blocked_users,     :key=>:source_id
  one_to_many :blocked_by_users,  :key=>:target_id, :class => BlockedUser

end

What would I put in here?:

# table => blocked_users, fields => "source_id", "target_id"

Class BlockedUser < Sequel:Model

  #fail => belongs_to :blocking_user_account, :class => User, :primary_key => :source_id
  #fail => belongs_to :blocked_user_account,  :class => User, :primary_key => :target_id

end

How would I refer to the User model from the BlockedUser model?

I tried the fix below and am confused on the following error; With the BlockedUser class restructured like so:

class BlockedUser < Sequel::Model
  many_to_one :blocking_user, :class=>:User, :primary_key => :source_id
  many_to_one :blocked_user,  :class=>:User, :primary_key => :target_id
end

I get the following error:

.9.3p0 :003 > BlockedUser.all.first.blocked_user
   INFO - (0.000427s) SELECT * FROM `blocked_users`
NoMethodError: undefined method `blocked_user_id' for #<BlockedUser @values={:id=>1, :source_id=>1, :target_id=>2}>

This does execute the appropriate query, however:

class BlockedUser < Sequel::Model
  many_to_one :source, :class=>:User
  many_to_one :target, :class=>:User
end

BlockedUser.all.first.source
  • 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-06T17:23:59+00:00Added an answer on June 6, 2026 at 5:23 pm

    You should specify the class name as a symbol (and use many_to_one instead of belongs_to):

    class BlockedUser < Sequel:Model
      many_to_one :blocking_user, :class=>:User, :primary_key => :source_id
      many_to_one :blocked_user,  :class=>:User, :primary_key => :target_id
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why would anyone distribute an entity (for example user ) into multiple tables by
Originally I had two tables in my DB, [Property] and [Employee]. Each employee can
Say I had the two tables below, how do I find all questions with
If you had two snippets: (global-set-key \C-d delete-char) and (define-key global-map \C-d delete-char) Is
if I have two tables: files(id, owner) and share(file_id, user) , where owner and
If you had to design a database with paid users and trial users would
So I recently created an HABTM relationship between two models (project & user). Before,
I have two tables that I'm joining (in order to get the username from,
I have two models: User and Store class Store < ActiveRecord::Base belongs_to :user class
My database model has 2 particular tables in it that require a many-to-many relationship.

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.