DEV Community

loading...
Cover image for Rails Home Flip Project

Rails Home Flip Project

craigsmith789 profile image CraigSmith789 ・2 min read

This Rails project was going to be more complex than my previous Sinatra project since I would be using 5 models and the various relationships between them.

I decided on building an app that would track home renovations. On paper, it looked great. A User would sign up or log in. Next, they could add a new Home or select from previous ones. Projects would be added to Homes. The Projects were then assigned to Contractors and lastly, the Contractor could add the Tasks needed to complete the project.

Rails generators made some easy work of creating the Models, Controllers, and Tables and provided an early confidence boost. Now it was time to start writing some code. It did not take long at all for me to realize that the level of complexity involved in getting all these models working together was much greater than I had anticipated. Creating the New and Edit forms for each model was streamlined by using Rails form_for .
form_for

One form could be displayed for both New and Edit and Rails would handle each of the forms appropriately. Other form helpers such as collection_select simplified the index view process.

collection_select

Nested forms and nested routes were essential tools for setting up the additional views and being able to display the correct data from multiple models. For example, nested forms allowed me to combine adding a new project and assigning a contractor on the same form. If I needed to display all of the projects for a specific home I could use the nested route homes/14/projects?
Another requirement of the project was to add third-party login. I selected Facebook. I had a small amount of prior experience with this so I assumed it would not be too difficult. I used the Omniauth and Omniauth-facebook gems to accomplish this. This also took much longer than I had anticipated but with a lot of patience it was eventually up and running.
I found the transition from Sinatra to Rails to be more difficult than I thought it would be. I must confess that there were many very frustrating moments while working on this project. If you happen to be experiencing the same level of frustration, all I can say is hang in there and keep addressing those error messages one at a time.

Discussion (0)

pic
Editor guide