Roles

Hi Ben,

Here's what I've been working on along with some questions. I commented out my code since I couldn't get it to work.

RAILS CONSOLE: How do I get all premium users from the console? I was trying User.find_by_role("premium").count and a couple of things I found on stackoveflow, but couldn't get them to work.

APP:

1. I was trying to refactor the page/show.html.erb (line 56) so that a page owner won't be able to see himself/herself as a 'collaborator'. I tried to use an if statement along the lines of: <% if user.record == current_user %> # then they can't see themselves


2. I was trying to make it so that if a page is private, normal users can't see it in the main index page. I added a migration to my db/migrate/CreatePages file with a public:boolean option. I got that to work and was able to change a wiki in rails by using x=Page.first -> x.update_attribute(public: false). I was trying to update the policies using from bloc and the video you sent, but couldn't get that to work.
I commented out the codes on:

views/pages/show.html (line 72)

app/policies/application_policy (lines 10, 16, 42)

Page.rb (lines 14-16)

page_controller.rb (line 3)