How it all started. The idea this time around came easy. A recipe database, users needed to have accounts but by doing so they could create, edit and delete their own recipes. While also being able to see other users recipes. So the concept was easy. Functionality is always the hardest part.
I started off with corneal
gem install corneal
This was truly helpful, it gave me everything I needed and way more. As I continued to add gems to my gemfile to add the functionalities I wanted, I realized that I needed to clean up the unnecessary gems I had installed as they were not working with the new ones I was adding.
For a while everything was great, I was getting the idea of models and views, I could create a form easily, work with my database. Then I hit a few roadblocks, I am a true believer that you learn more from what goes wrong than what goes right.
My biggest learning curve in this project was using REST architecture.
REST is an HTTP method. Basically it is a way to send and receive requests from the Client to the Server. You can have 4 requests:
GET - This is the read access. Where you can access the actual resource.
POST - This is where you can create a resource. Any new creation would be done through POST.
DELETE - This is the easiest concept. This is how resources are removed.
PUT - This is used for updates of an existing resource.
When you are designing RESTful Web Services there are some common practices that make this all possible.
Validation - This validation was crucial when creating a login and sign up experience for users. The User had to create a password so creating a secure way of keeping these passwords and then validating that the login was correct prevents any attacks on the data.
Session Based Authentication - This connects to the Validation step. When the user was first validated, in my project I made sure to save a Session[:user_id]. This was a short piece of code that became part of my authentication as the user tried to edit and delete their recipes down the line. This feature was the hardest to actually work, due to having to connect multiple recipes to one user and giving that user full autonomy to change them. Yet have an inability to change other user's recipes.
The Work is Never Done
Finally as I had finished my project and was going one last walk through the functionality of it, I realize that my edit button stopped working.
I tried rerouting it, updating my edit form, using pry, and reconnecting my edit button, but nothing worked.
I could not figure out how the functionality that had once worked no longer was working. I took a similar approach to my 2nd road block and decided to recode that portion on step at a time to find the missing piece. Once again I realized that my params were not saving the id => 1 but instead were saving id => :id this was causing major errors in my program.
The problem was just knowing the problem did not help fix it, I had to work through different refactoring, adding, deleting and breaking different portions of my code until figuring out that my connections were not correct and I had not added the dynamic factors so that my code took id as a number.
I am very happy to say that finally my program works end to end. It has been an awesome accomplishment.
Top comments (0)