Allowing Unauthenticated Access
However, our store’s product index and show pages should be accessible to everyone. By default, the Rails authentication generator will restrict all pages to authenticated users only.
To allow guests to view products, we can allow unauthenticated access in our controller.
class ProductsController < ApplicationController allow_unauthenticated_access only: %i[ index show ] # ...end
Log out and visit the products index and show pages to see they’re accessible without being authenticated.
Proudly built by Evil Martians based on the Rails Guides.
Files
Preparing Environment
- Preparing Ruby runtime
- Prepare development database