Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Can't display/access products with Rails

Can't display/access products with Rails

sam1905
New Member
4 0 0

So this is my Products controller

 

 

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

 

 

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

 

<h2>Products</h2>
<% @Anonymous.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)