Introduction to Authorization and How to Install the Petergate Gem
Authorization is an important component of most web applications. In this guide we're going to walk through what authorization is, and then how we can install a RubyGem called Petergate, that will enable us to easily integrate authorization into our codebase.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

In this section, we are going to talk about authorization and how we can integrate that into our app. You may have noticed we don't have an authorization section here in our icebox. I'm going to add it straight to the backlog. Authorization is deciding on a permission structure for users. That's the functionality that we're going to build, as far points, I'm going to give this two points. This is a feature and we're going to say "Integrate authorization for the app's permission structure." For the tasks

  • Install the petergate gem
  • configure gem
  • implement code for authorization

Click save on and let's get started.

I have the petergate gem open, I recommend going to the creator's GitHub (Isaac Sloan) it is a great education on how to how to write great looking code.

Look at the code for the petergate gem, you can see that this is going to addcode to preexisting files. It is also going to create a migration file.

I'm going to go to rubygems.org and search for petergate. Rubygems.org actually gives you the exact full script including the version number. Imagine that you only had gem petergate right and you didn't specify any version, then you leave it in your app for a couple of years, eventually, there may be a significant version change. Since you didn't specify a version, when you run bundle update it could override what you have and it may have conflicts with your version of rails or something like that. It's always considered a best practice to come to rubygem.org specifically and select this from the gem file.

Switch to the terminal, we're back in the DevcampPortfolio. I'm on the branch master, let's create one called authorizations

  • git checkout -b authorization.

Now we're switched to that branch, open the gemfile. If I scroll all the way down to the bottom I paste in gem 'petergate', '~> 1.7'

Now coming back to the terminal run

  • bundle install

this is going to pull down petergate, everything there looks like it was good.

type

  • git status
  • git add .
  • git commit-m "Installed petergates gem for authorization"
  • git push origin authorization

Let's come back to our project dashboard. I'm going to click on install the petergate gem. In the next guide, we're going to go through the full set of installation instructions.

Resources