My First Ruby on Rails Project

My First Ruby on Rails Project and some things I learned in the process…

College Todo Screenshot: User profile(show) page

For my first Rails project I continued with my college themed Sinatra project. After completing the Sinatra project and learning more, I thought I could do a bit better with my college checklist. So I improved upon my first project, the Sinatra College Plan Checklist. College-Todo-Rails is a simple app where users can keep track of tasks related to the college application process and share stories about their experiences.

Main technologies and gems:

  • Ruby
  • Rails 5.0.1
  • Bootstrap — gem ‘bootstrap-sass’
  • User authentication — gem ‘devise’
  • Facebook authentication — gem ‘omniauth-facebook’
  • Heroku friendly app configuration — gem ‘figaro’
  • Pagination — gem ‘kaminari’
  • Pretty URLs — gem ‘friendly_id’
  • Postgres database for Active Record — gem ‘pg

For user authentication I used Devise and Omniauth-Facebook. Users can create an account or sign-in with their existing Facebook account. DigitalOcean has a very good tutorial on using Devise and Omniauth, I found it to be quite helpful.

After users login they create their checklists for each college they are applying to. Users can also add college visits, date and time. College visit date must be in the future. I had to create my own method and error to prevent past dates from being accepted in the form.

#app/models/college.rb
def college_visit_cannot_be_in_the_past
if college_visit.present? && college_visit < Date.today
errors.add(:college_visit, "can not be in the past, please
choose a future date!")
end
end
Screenshot of Checklist Form with Error Warnings

The user profile page displays their checklist and a countdown in days until their visit. Also displayed on the user show page is a stories section, which shows the title of their story, date created and a number count of comments.

The story section is a new addition from my Sinatra version. I thought it would be a nice feature to let users share about their experiences and comment on each others stories. I used the ‘kaminari’ gem for pagination, showing only 10 stories at one time. Also users can view stories by most recent or by most comments.

Screenshot: Stories Index page (default sort view)
Screenshot: Stories Index page (sort by number of comments)

I used the ‘friendly_id’ gem to create prettier, easier to read URLs. Friendly_Id allows you to turn generic URLs into more relevant URLs.

With the friendly_id gem

a generic url such as:

https://college-todo-rails.herokuapp.com/stories/012345

becomes:

https://college-todo-rails.herokuapp.com/stories/listen-to-the-log

I really enjoyed working on this project, learning new gems (at least new to me) and pushing my rails project to heroku. Look forward to improving it and adding dynamic features with jQuery. You can find my code on my github page: https://github.com/cmiller36/college-todo-rails or check out the project on heroku: https://college-todo-rails.herokuapp.com/. Thanks for reading :)