0

When I make a search, my url result is:

/refinanciamentos/index?utf8=✓&pesquisa_func_cpf=**111.111.111-11**&pesquisa_func_matricula=&commit=Pesquisar

And after that show all search results, I click on button:

<%= link_to 'Reserva', refinanciamentos_reserva_refinanciamento_path, :class => 'btn btn-primary' %>

And this button go to other view and other method. How make for pass the search params (pesquisa_func_cpf=111.111.111-11) for other method in same controller? The method for search is index and I need pass the params for method reserva_refinanciamento, how make? I don't have no one idea about this =/

--------------------- UDPDATE: This is my controller

      def index
        if params[:pesquisa_func_cpf].present?
          @funcionarios = Funcionario.pesquisa_cpf(params[:pesquisa_func_cpf]).all
          @autorizacoes = Autorizacao.pesquisa_func_cpf(params[:pesquisa_func_cpf]).all
(...)


  def reserva_refinanciamento
   # nothing here 
Elton Santos
  • 571
  • 6
  • 32

1 Answers1

1

You can do like this

<%= link_to 'Reserva', refinanciamentos_reserva_refinanciamento_path(:pesquisa_func_cpf => params[:pesquisa_func_cpf]), :class => 'btn btn-primary' %>

Then in reserva_refinanciamento method you can able to get the search data by params[:pesquisa_func_cpf].

Sukanta
  • 585
  • 3
  • 6
  • But the method reserva_refinanciamento don't search. This method is response for save on form the datas and the params on search will just show on view in this same method – Elton Santos Apr 07 '16 at 18:33
  • you mean after save want to pass the search params to other method/action ? – Sukanta Apr 07 '16 at 18:42
  • Example... I have a method index = my seach, this method pass params for method reserva_refinanciamento, and this method receive the params and show on view and register on forms – Elton Santos Apr 07 '16 at 18:48
  • can you please add you controller here ? – Sukanta Apr 07 '16 at 18:53
  • in method reserva_refinanciamento I put this: @funcionario = Funcionario.pesquisa_cpf(params[:pesquisa_func_cpf]) and my view this: <%= @funcionario.pessoa.nome %> but dont work. Get this error undefined method `pessoa' for – Elton Santos Apr 07 '16 at 19:32
  • then above answer will work because refinanciamentos_reserva_refinanciamento_path(:pesquisa_func_cpf => params[:pesquisa_func_cpf]) pass the params to reserva_refinanciamento method – Sukanta Apr 07 '16 at 19:48