For my third project for Flatiron, I did a project with Rails. The website I created was a game review website. One of the biggest problems I had with the website how to set a game with a review.

When access the new review form, there are two forms that the user can get.

New Review from Game Show
New Review from Review Index

When I started to create the website, I wanted a way for users to create reviews for games not on the website. So I created a way to check to see where the user was coming from, and to see if they are creating a review for an existing game.

_form for Review

In my form, I nested a form for a new game. I also did not want the new game nested form to show every time a user went to the form. So, I built 2 helpers to check to see where the user came from.

Review Helper Methods

The first helper is to check if the user is making a new review or editing an older review. The first check in the method is to see if there is a param for the game_id. When user’s come from the game show page, they have a param for the game they were just looking at. So then we’ll set the hidden_tag to that game we just came from.

The second check is to see if review has a game_id attached to it. If it does then it will set the hidden_tag to that and it update the review to the game_id and update it to the same game as it was before, and keep the game the same.

If the method doesn’t find a game_id from those checks, it will be nil and then it goes to the new_game? method. In this method, we check to see if it passed a check in the new_or_update? method. If it didn’t and we get nil, then we set this method to true and let the form show the nested form for new game. If they new_game? check fails, then the nested form does not show

Overall, I enjoyed working on this project, and had a lot of fun building it. If you want to see more about this project, you can take a look of it here: