DEV Community

Cover image for A Stitch in Time...

Posted on • Updated on

A Stitch in Time...

Photo by Bev Lloyd-Roberts from FreeImages

For my first Rails project I created a knitting pattern sharing app where users can CRUD patterns as well as rate and comment on patterns. Even though there are tons of gems available that can make building your app much easier, I decided to write the code myself so that I could fully understand what was going on behind this ‘Rails magic’ I always hear about. It is pretty magical, but let’s acknowledge where that magic really comes from. Rails is the product of hard-working developers who have made our app creating journeys much easier, and for that I want to start off with a great big thank you!

Working on this project has been really enriching and I’m looking forward to adding a few more features and improved functionality as well as some styling to this fun little app. At this stage, everything I have learned so far is coming together quite nicely and I am feeling more confident in my programming abilities. That being said, I still have points of total confusion mixed in with the oh-so-great feeling of getting things working successfully. But, I am smart enough to be aware that:

“The more I learn, the more I realize how much I don't know.”
Albert Einstein

Alt Text

Photo by Julia Freeman-Woolpert from FreeImages

There are so many amazing parts and pieces to this project that I had a tough time narrowing down what I wanted to focus on for this blog. I could certainly talk about the MVC structure, or discuss nested routes or how to write validations or even go into detail about creating views. While all of this is incredibly important, I realized that the organized approach I took with this project ended up working out really well (surprise!) and that I want to emphasize that in case anyone needs to hear it.

Before I even wrote one line of code, I made sure to clearly define my associations and the user story. I'll give you a peek here:

User story

Users will be able to:
    -sign up, log in, log out

Users can:
    -CRUD patterns
    -rate and comment on patterns

Wireframing (attributes and associations)

    Models: User, Pattern, Comment

    User attributes:

    User associations:
        has_many :patterns
        has_many :comments
        has_many :commented_patterns, through: :comments, source: :pattern

    Pattern attributes:
        level :integer
        instructions :text

    Pattern associations:
        belongs_to :user
        has_many :comments
        has_many :users, through: :comments

    Comment attributes:
        rating :integer
        content :text

    Comment associations:
        belongs_to :user
        belongs_to :pattern

Having all of this clearly written out gave me solid direction for this project. What a big difference it makes! Like anything else in life, it pays to be organized and prepared. Something else I found really helpful was to break the project down into chunks that I could tackle day by day. In previous projects, I was overwhelmed at times thinking about all the pieces that needed to be done. This time though, since I gave myself reasonable amounts of work to do daily and I had some direction as to where I should be each day, I felt much less stressed and was able to focus on the joys of creating and the buzz of all that logic processing inside my brain.

Before you go, I want to share something I discovered that I will definitely be using next time: GitHub projects. Yes, I realize there are many wonderful apps for organizing your projects, but here’s the thing, you’re already working with GitHub (right?) so why not use their features? Not only will it help you stay on track and keep all your details together, you can also add GitHub functionality to your project board. Sadly I did not know about this great resource in time to use for this project, but I will be using it in the future, so I'll let you know how my experience went. Here's a tiny preview:

Alt Text

Thanks for reading and happy coding!

Top comments (0)