Cannot see the wood from the trees on this one so any help yuo can provide to this newbie issue will be very much appreciated!
My 'Office' view displays the office products found in the product database. More than one product is displayed within this view so i want users to be able to click on an office product which goes to the 'show' view that displays just that products details.
My store controller looks like this: -
class StoreController < ApplicationController def index @products = Product.all end def show @products = Product.find_by(:id) if @products.nil? redirect_to action: :index end end
The link_to code within the Office view looks like this: -
<p class="showArticle"><%= link_to 'Show Article', store_show_path %></p>
The code for the product in the show view looks like this: -
<%= @products.title(:id) %>
The office products are displayed properly within the office view. When the products link_to is clicked on the browser redirects using the action: :index as @products.nil? is found to be true.
How should i be passing this products details into the show view so that the products details are seen?