Admin and Admin Page


Premium Content - Free Preview

Let's create an Admin user and code our own page for admins.

Creating an Admin

The simplest way to create an admin is to add a boolean admin column to users. Go ahead and do that.

Terminal Commands

The admin property can now be set from the rails console. Go ahead and set your user account to be an admin.

Console Commands

Custom Admin Page

Let's create a page for admins to view sold out products. Try to do all the following tasks without looking at the solution:

  1. Create a route sold_out that sends visits to the products controller action sold_out.
  2. Create a controller method sold_out in the products controller, and set the instance variable @title in it to your desired title.
  3. Create another instance variable @products and assign it all sold out products.
The Code

End of Free Content Preview. Please Sign in or Sign up to buy premium content.

Contact Us
Sign in or email us at [email protected]