Rails Project - Pollen

ajrom

A.J. Romaniello

Posted on April 27, 2021

Rails Project - Pollen

Pollen

For my rails portfolio project I decided to build out an application base that will later be built on to be used for a product matching API.

Why

I have heavy feelings towards sustainability and setting up a website that will promote this was of great interest to me.

The Challenges

I wanted to keep this a barebones as possible, no generators, and no gem madness. Which lead to me learning a lot more about the Rails framework and SCSS.

User Authentication

At first I wanted to rely only on omni-auth and build out my own custom RESTful routes for logging users in, although decided to go with devise.

Reducing Devise

Devise adds a ton of useless stuff that I did not need for my application. I went through most of the code and views that devise included and customized and built my own methods based on the sections that I needed.

This helped me keep my application smaller as well as having a deeper understanding to how tools such as devise work from the inside.

Default Users

Since I originally was planning on not storing user passwords or letting them 'create an account' via my web application (only log in via third party). I needed to change a couple of things.

  • Add Bcrypt
  • Create a Sign Up form
  • Allow users to sign in via email/password
  • Generate a fake password for third-party login ins

All in all this seemed like a large task to take on and the devise wiki made it seem even worse. Although if you have a decent understanding of html forms and rails form helpers creating dynamic links and login/signup pages actually isn't too difficult.

Useful Things I Learned

Layouts

Layouts are extremely important for keeping your views clean and lets easily style your application dynamically.

Helpers

Helpers are well.... helpers. Use them! No need for a user to see any malformed data or spend a ton of time nesting objects within links.

My favorite use case was creating a helper to wrap an entire div element to its associated path. Usually you would have to do:

<%= link_to '/login' do %>
   <div>
     <h1><%= @resource.name %></h1>
     <p><%= @resource.description %></p>
   </div>
<% end %>
Enter fullscreen mode Exit fullscreen mode

Which would be much better if you could call something like:

link_card_to('/login', @resource)
Enter fullscreen mode Exit fullscreen mode

Conclusion

I learned a ton over this project from rails routing, too layouts, to helpers, too SCSS. This was an awesome journey and I am excited to get into the Front-End frameworks such as Vue.js and React.

💖 💪 🙅 🚩
ajrom
A.J. Romaniello

Posted on April 27, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related