Ruby Rails Has_Many fetching data

I am trying to fetch the information from books associated with a
customer but seem that the middle association doesn’t works

Here my model

Book
has_one :book_manager
has_one :customer, :through => :book_manager

Customer
has_many :book_managers
has_many :books, :through => :book_managers

Book_Manager
belongs_to :customer
belongs_to :book
The field are has follow

Book Customer book_manager
id id id
description email customer_id
password book_id
first visible
last
When fetching the information in my def edit, the following is
successfull

@book = Book.first
@book = Book.last
The following seem to fails

@customer = Customer.find(params[:id])
@book = @customer.books.first
@book = @customer.books.order(“created_at DESC”).first
Is there something i miss?

I also try to verify by creating an index for book_manager controller
and view and nothing appears, its seems its empty. The way i created the
books was as follow

BookController

def create
@book = current_customer.books.build(params[:book])
if @book.save
flash[:success] = “Book Created”
redirect_to root_url
else
render ‘customer/edit’
end
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs