Search inside another scaffold rails

-1

I have a problem, an example I created two scaffold book and loan, then I created a controller and an index called report:

rails generate controller RelatoriosEmprestimos index

I want to make specific searches of scaffold loans on this controller that I created.

I need to solve this as soon as I can.

    
asked by anonymous 12.06.2018 / 17:10

1 answer

0

It depends on how you want to search. The basics are:

class RelatoriosEmprestimos < ApplicationController

  def index
    @emprestimos = Emprestimo.where(campo1: 'condicao1', campo2: 'condicao2')
  end
end

The "search" in question is done by the model in the controller. It could be any controller and any method would be the same thing.

But it's the basics. If you want a more complex search system, you will have to see other options.

    
13.06.2018 / 03:48