Pass parameter of selected line to another RUBY view

0

I am a beginner in ruby. I have a table in a view, which when I click on the line / item it should pick up the ID of the selected line and move to the other view that will be triggered, I am 3 days searching about and can not implement.

The view that should pick up the ID or another parameter so that in the other I can handle the select to bring more detailed information >>

<td>
  <%= link_to pedido.id, detalhes_backoffice_pedidos_path(:pedido_id => pedido.id) , :onclick=>"window.open(this.href,'create_company', 'height=600, width=600');return false;" %>            
</td>

The view ("popup") that is called when clicked on the request id. Note: I have tried in many ways, and at the moment it is like this ... > > > >

<div class='container-fluid'>
<div style='display: block;' class="col-xs-6 esquerdo ">
  <label>Num.pedido<%= pedido.id %></label> <br>
  <label>nome</label> <br>
  <label>telefone</label> <br>
</div>

Controller > >

class Backoffice::PedidosController < BackofficeController
.....
def detalhes
 render :layout => "application"

@pedido = params[:pedido_id]

end

I'm totally lost, after trying so hard.

    
asked by anonymous 01.09.2017 / 00:25

1 answer

0

Ok, maybe it's late, but I'll try to help. You could try this:

<td>
  <%= link_to "sua view (Pedido) / #{pedido.id}", detalhes_backoffice_pedidos_path(:pedido_id => @pedido.id), :onclick=>"window.open(this.href,'create_company', 'height=600, width=600');return false;"  %>            
</td>

or:

<td>
  <%= link_to "sua view (Pedido) / #{pedido.id}", detalhes_backoffice_pedidos_path(pedido_id: @pedido.id), :onclick=>"window.open(this.href,'create_company', 'height=600, width=600');return false;"  %>            
</td>

Ok, let me see if we are thinking the same, this detalhes_backoffice_pedidos_path , is where you want to send pedido.id?

change here too, please:

def detalhes
       render :layout => "application"
       @pedido = Pedido.find(params[:pedido])
end

ps:

Just a tip, when generating your codes, generate in English. And from a search on the Stack website in English generally, the answer to your question is there. ( link )

    
19.09.2017 / 20:55