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

  • Home
  • SEARCH
  • 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 8311053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:41:05+00:00 2026-06-08T19:41:05+00:00

I am not sure how to create an event at all time but still

  • 0

I am not sure how to create an event at all time but still keeping data integrite correct.
Here are my models

Customer

  id
  first
  last
  email

Book

  id
  description

Book_Manager

  customer_id
  book_id
  visible

In order to do this I have to use a has_many relationship and his describe has below

Book
has_many :book_managers
    has_many :customers, :through => :book_managers
Book_Manager
    belongs_to :customer
    belongs_to :book
Customer
    has_many :book_managers
    has_many :books, :through => :book_managers

The idea is to see the data already created from previous time, which mean I would have to create a query where Book = Book_Manager Table where customer_id = current_customer and created_last. I am not to sure how would i create a query like this in the book controllers. I believe it may look like has follow for the query. I am correct? Current customer is the current customer in sessionHelper method

@report = BookManager where customer.id == current_customer.id AND created_last.last

Last but not least, everytime the customer modify the text by pressing save, The action create would be executed, and create a new book_manager with the correct 3th model books associated with and customer also associated with the book manager.

I have the following code but i am not sure if its correct

class BooksController < ApplicationController
    def edit
        @book = Book.find(params[:id])
    end

    def create
        @customer = Customer.first
        @book = @customer.BookManager.build(params[:book])
    end
end
  • 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-08T19:41:09+00:00Added an answer on June 8, 2026 at 7:41 pm
    Book
      has_many :book_managers
      has_many :books, :through => :book_managers
    
    Book_Manager
      belongs_to :customer
      belongs_to :book
    
    Customer
      has_many :book_managers
      has_many :customers, :through => :book_managers
    
       Book                Book_Manager          Customer
    |-------------|       |-------------|       |---------|
    | id          |-1---*-| book_id     |       | id      |
    | description |       | customer_id |-*---1-| first   |
    |             |       | id          |       | last    |
    |             |       |             |       | email   |
    |-------------|       |-------------|       |---------|
    

    As you have the have_many through you don’t need to refer the join table (Book_Manager). You can access it directly:

    @customer = Customer.first
    @books = @customer.books #return all books
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure how to describe this but I'm trying to create a base
I'm trying to create a simple search page, but I'm not 100% sure how
I am not sure it's a good idea to try to create different kind
I'm not sure if its the best idea to create a background job that
I'm not sure how I would do this in Javascript. I want to create
I'm trying to create a login system using PHP, and I'm not quite sure
I'm not sure if this is possible but I want to see objects created
On my app i am creating a real time trace (not sure how yet
My question..not even sure if this is possible but curious from others... I have
Not sure I fully understand what phpmyadmin does. I created a database in phpmyadmin,

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.