Search inside another Rails scaffold

Asked

Viewed 34 times

-1

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

rails generate controller RelatoriosEmprestimos index

I want to do specific scaffolding searches on this controller I created.

I’m really looking forward to this since I thank you

1 answer

0


Depends on how you want to look. The basic is:

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 that would be the same thing.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.