i am new to ruby/rails, and i am struggling with the find_by method.
Heres some background on what i am trying to get done:
I have a User object, and a Book. User has_one Book, and Book
basically, i have a combo box which displays all the books, i get the
id the book is stored in, from the form and then in the user model
class, i try and find the according and assign the according book,
with this find method:
self.book = Book.find_by_id(b_id)
unfortunately i end up with this error:
Mysql::Error: #42S22Unknown column ‘books.user_id’ in ‘where clause’:
SELECT * FROM books WHERE (books.user_id = 1) LIMIT 1
I dont understand why it is searching the user_id column (which doesnt
exist), rather than id …
At first, i thought something was wrong with my Book.find_by
statement, but i tried the same line in an ActionMailer, and it worked
can someone please clear this up?