如何让它发挥作用?
books_controller.rb:
1)
def index
@books = Book.where(library_id.present?)
end
2)
def warsaw_books
@books = Book.where(city == 'Warsaw')
end
答案 0 :(得分:0)
1)查找library_id
不为零的记录:
def index
@books = Book.where.not(library_id: nil)
end
2)查找city
为'Warsaw'
的记录:
def warsaw_books
@books = Book.where(city: 'Warsaw')
end