ruby on rails 3 - render show page inside index page, how to put a different id on each modal -


I am using a model to pop up the show page inside the index page ..... someone Click on the product for some reason, the same name is popping on the model for each product

I know that this is a simple fix, please help ... This is my code for the new Rail :

View

_show.html.erb

  & lt; Div id = "mymodal" class = "modal hidden fade" role = "dialog" area-labeling = "mymodel label" axia-hidden = "true" & gt; & Lt; Div class = "content-internal hero-unit" & gt; & Lt; H1 class = "pump-up center" & gt; & Lt; Br> & Lt; Strong & gt; Coming soon. & Lt; / Strong> & Lt; / H1> & Lt; Br> & Lt; Br> & Lt; P & gt; & Lt; B & gt; Name: & lt; / B & gt; ** & lt;% = @ product.name% & gt; ** & lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt;   

index.html.erb

  & lt; Div class = "row" & gt; & Lt;% @ products.each do | Products | & Gt%; & Lt; Div class = "span3" & gt; & Lt;% = Render: Partial = & gt; 'Product / Show' ,: Local = & gt; {: Product = & gt; Product}%> & Lt; A href = "# myModal" role = "button" data-toggle = "model" & gt; & Lt;% = (image_tag product.photo (Medium))% & gt; & Lt; / A & gt; & Lt; / Div & gt; & Lt;% end% & gt; & Lt; / Div & gt;   

Model

product.rb

  class product & lt; ActiveRecord :: Base attr_accessible: name,: photo end   

controller

products_controller.rb

  Class Product Controller & lt; ApplicationController def Show @ Product = Product.Fund (Parameters [: ID]) End Def Index = Products = Product.All End End    

OK this issue is with this code.

Index.html.erb

should be

  & lt; A href = "# myModal & lt;% = product.id%>" Role = "button" data-toggle = "modal" & gt;   

and change ur_show.html.erb to

    

This job should be done.

In addition, I see that you are not using the local variable which has been passed from the index action. You may be a problem that you are using @product, using only 'product' which see index.html. Being passed from ARB

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

jsp - Google line chart x-axis shrinks on transition -

java - Reaching JTextField in a DocumentListener -