Rails Project - Pollen
A.J. Romaniello

A.J. Romaniello @ajrom

About: Just a place to put things others may find useful.

Location:
Colorado
Joined:
Jan 28, 2021

Rails Project - Pollen

Publish Date: Apr 27 '21
2 3

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.

Comments 3 total

  • Travis Fantina
    Travis FantinaApr 27, 2021

    Do you have a link to the final version? Or a repo?

    • A.J. Romaniello
      A.J. RomanielloApr 28, 2021

      Hey I have updated the header to include the link to the repository. Thanks for the interest.

      I am going to be rebuilding this using generators (for cleanliness) and too now further my knowledge of generators.

      • Travis Fantina
        Travis FantinaApr 28, 2021

        Cool I'll try to set this up locally if I have some time this week. Good work.

        Generators are nice for a quick MVP but I don't think you need to worry about them much, I have found that I rarely use them after getting the hang of the files they create I generally just create those files by hand as needed like you did with this project.

Add comment