Elton Santos
Elton Santos

Reputation: 581

Pass params for other method

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 

Upvotes: 0

Views: 115

Answers (1)

Sukanta
Sukanta

Reputation: 585

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].

Upvotes: 1

Related Questions