Pass parameter of selected line to another RUBY view

Asked

Viewed 460 times

0

I’m a beginner in Ruby. I have a table in a view, that when I click on the line/item it should take the ID of the selected line and pass to the other view that will be triggered, I’m 3 days searching on and I can’t implement.

The view that should take the ID or other parameter so that in the other I can treat 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. Obs.:I tried in many ways, and at the moment she 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....

1 answer

0


Okay, maybe it’s late, but I’ll try to help. You could try it:

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

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

change here too, please:

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

ps:

Just a hint, when it comes to generating your codes, run it in English. And from a search on the Stack site in English usually, the answer to your doubt is there.(https://stackoverflow.com/)

  • Thank you! But I had already solved, I’ve been studying a lot and this is the basics I should know, and about the tips, thanks again, I have to improve this.

Browser other questions tagged

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