I love your style: Learning Ruby on Rails

Having spent just over two years working as a front-end developer on Ruby on Rails projects I’ve become pretty handy with ERB, HAML & SASS but when it comes to looking further into the back-end stack I’ve been hesitant to do anything except look at the code and write the occasional simple helper for my views. I’ve had an idea for a while and I decided to bite the bullet and make it myself.

The site is I love your style. The idea is to be able to ask beauty or fashion questions directly to those people you admire, as an aside you can also ask the wider community. The grand vision is for it to be a Stack Overflow for beauty and fashion.

This post is simply a list of resources I used and things I learnt while developing the site.

User sign up and sign in

The first thing I knew I needed was for people to be signed in before they could ask or answer any questions.

It was quite straight-forward to walk through the tutorial (Ruby on Rails Tutorial: Chapter 7 Sign Up). I started by blindly copy and pasting the code examples and trying to keep up with what was being explained, by the end I still hadn’t had that moment of clarity when everything clicks into place but I was happy I’d made progress.

Active Record Associations

Once the user is signed in, they need to be able to ask and answer questions. Having a Computer Science background and having worked for a short time as a DBA so I knew that the ideas behind Active Record Association was what I needed.

It was during this process of associating many answers to one question and that a question belongs to one user that I had my epiphany! It felt AMAZING to finally understand – albeit a basic understanding.

Heroku

Next I needed to deploy the app. This involved running through articles on Getting Started with Rails 4.x on Heroku and Heroku PostgreSQL.

SQLite3 and PostgreSQL

No idea if this is good to do, but I use SQLite3 on development and PostgreSQL on production. I wanted to discover how to manipulate the tables from the command line and found it was different on both environments.

Development
rails db – the SQL statements are case-insensitive. .quit to exit.

Production
heroku pg:psql – the SQL statements are case-sensitive. \quit to exit.

Paperclip and Amazon Web Services

I wanted the user to be able to attach a photograph to their question, for instance if they wanted to find out how their outfit looked today, so I searched for a gem that would help me with this. Paperclip seemed to be what most people were using.

Using readme on the GitHub repository and this article: Uploading Files to S3 in Ruby with Paperclip I managed to get this working and also enable it for uploading an image to the user’s profile.

Action Mailer

It’s usual for an application to send the user a welcome email once they’ve signed up. I also wanted a user to be able to direct their question to a particular person, so that gets sent via email as well.

I worked through the Action Mailer Basics guide to get this working.

Email verification link

Now I want to have the system email the user an email verification link so I know they are a real person. The obvious choice for this is Devise. I got half way through using this before realising it wasn’t so easy to retrofit this in once you’ve got a UsersController and all your routes set up. If I was to do this project again I would start it with Devise rather than the sign up tutorial.

That is still work in progress.

Other new bits and pieces

  • Added a custom DNS record to link the herokuapp url to my own domain name
  • Set up a redirect from http://iloveyourstyle.co.uk to http://www.iloveyourstyle.co.uk
  • Created a seed file to populate empty an category table
  • Set up environment variables in bash_profile to keep sensitive passwords and keys hidden
  • Figure out I need to compile assets before deploy (still need to automate this)

Am I full-stack now?

I like to joke about being full-stack. I have the awareness to know I’m only a master in front-end development but I have already seen that I can do lot more on work projects without needing to ask the back-end developer for their help on something that’s actually pretty basic.

One comment

Add your comment

Your email address will not be published. Required fields are marked *