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 index.html.erb Model product.rb controller products_controller.rb OK this issue is with this code. Index.html.erb should be 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
& 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;
& 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;
class product & lt; ActiveRecord :: Base attr_accessible: name,: photo end
Class Product Controller & lt; ApplicationController def Show @ Product = Product.Fund (Parameters [: ID]) End Def Index = Products = Product.All End End
& lt; A href = "# myModal & lt;% = product.id%>" Role = "button" data-toggle = "modal" & gt;
Comments
Post a Comment