The DIY Life- My First Rails App

Mary Umoh
3 min readMay 31, 2017

--

The DIY Life officially marks my third portfolio project in the Flatiron School’s Learn Verified Program. I feel like I’m moving at a snails pace but I am learning. The DIY Life was exciting (and challenging) to create because I absolutely love anything/everything Do-It-Yourself. In the program, we’re always encouraged to create something that we genuinely like and now I understand why. I had this big vision of what I wanted the site to look like and what functionality a user would have. Then, there came making that vision come to pass with guidelines that included building nested forms, nested resources, scope methods, user authentication and the list went on.

Rails Assessment Requirements:

  • Use the Ruby on Rails framework.
  • Your models must include a has_many, a belongs_to, and a has_many :through relationship.
  • Models should include reasonable validations for the simple attributes.
  • Include at least one class level ActiveRecord scope method.
  • Include a nested form that writes to an associated model through a custom attribute writer.
  • Your application must provide a standard user authentication, including signup, login, logout, and passwords.
  • Your authentication system should allow login from some other service.
  • You must make use of a nested resource with the appropriate RESTful URLs.
  • Your forms should correctly display validation errors.
  • Your application must be, within reason, a DRY (Do-Not-Repeat-Yourself) rails app.

Learn.co prepared me for this. There’s a plethora of lessons, code-alongs, and videos covering these very topics. I just didn’t know where to start or how I would create this vision I had in my head. So, prior to jumping in I got on draw.io and began to think about what tables I wanted and the associations(this still trips me up) they should have.

Afterwards, I set up Omniauth and Devise for users and views. I made use of the DotEnv gem to load environment variables from .env. Devise assists with Omniauth set-up so I knew it’d be a breeze, NOT! Things got nasty and bugs ran rampant. I wanted users to signup with a name field in the view. I could not figure out what I was doing so wrong. That is until I read the Devise documentation and slapped myself for not throughly reading it prior. If you want to customize and add a new attribute you must add a before action to the application controller that’ll configure parameter sanitization and permit additional parameters.

application_controller.rb

Next, I began working more on how my associations would work and creating a nested resource. When a user successfully signs up they are able to complete all CRUD actions in regards to creating a project. They can also view projects created by other users but cannot make any changes to those projects.

routes.rb
project.rb

Users are able to add an inspirational picture to their project which was possible using the Paperclip gem. Following along with the documentation this time made it go smoothly. Well, almost. I forgot to include some code in the views but all was well after that!

I think one of the biggest problems I got hung up on was the styling. Literally, just getting positioning correct was a TASK. I was not expecting that and I didn’t want to lose focus from implementing functionality and understanding how things were working. I ended up using a bootswatch theme and the fonts awesome rails gem. I’m pleased with the aesthetics.

Check out a video walkthrough of The DIY Life below:

You can view the rest of my code here.

Check out one of my own DIY projects. Cost under $100!

Thanks for reading! Next up…Javascript!

--

--