Rookie coder here… I am currently building an ecommerce site in rails. I have brands and price lists on the left hand side of the results pages, these lists are often longer than the page itself, I would therefore like to put them into scroll boxes like here
I have tried putting then into iframes, using partials, but it keeps producing different errors each time, and seems more fiddly than it should be. I have only really been able to find relevant information from dated blogs etc. The code I have tried is variations of this…
View:
<iframe src="<%= url_for :action => 'brands' %>" scrollbars="auto" name="brands"></iframe>
Controller:
def brands
render :partial => 'brands', :layout => false
end
Partial:
<ul>
<% @brands.each do |prod| %>
<li><%= link_to(strip_tags(prod[0]).html_safe + " " + "(#{prod[1]})", params.merge(:brand => "#{prod[0]}")) %></li>
<% end %>
</ul>
This seems to throw up a “Couldn’t find Product with id=brand” error.
I also read that iframes may be a little old fashioned, so I am fully open to alternatives. Any help would be much appreciated!
No need to use iframes for this. You should just be rendering the partial in the view itself. And if you want scroll bars you should use CSS to make the height/width fixed and then set the overflow to scroll. Here is a link to help with that