Can't display/access products with Rails

sam1905
New Member
4 0 0

So this is my Products controller

 

 

class ProductsController < AuthenticatedController
  def index
    @products = ShopifyAPI::Product.find(:all, params: { limit: 10 })
    render(json: { products: @products })
  end
end

 

 

And this is how I want to display the products in views/products/index.html.erb:

 

<h2>Products</h2>
<% @products.each do |p| %>
  <p><%= p.title %></p>
<% end %>

 

 

And my route:

 

 

get '/products', :to => 'products#index'

 

 

But when I redirect my page to /products, I get this message:

 

sam1905_0-1644494089781.png

 

Which doesn't happen with all my other routes, so what am I doing wrong? Am I missing something?

 

Replies 0 (0)