DEV Community


Posted on

Quick Tips for Restful Routing from a beginner.

From being completely new to Ruby programming to learning the joys of Sinatra, the journey doesn't seem to end and I love it! My latest adventure, learning restful routes. Here a few simple things that I learned the hard way.

  1. Work on one piece at a time.
    This is something that should be common sense but its so crucial. I made the mistake of assuming certain data would pass correctly because it had worked on previous implementation, but I never stopped to think about routing being correct. This obviously caused me to chase some invisible error that was no where near close to what was actually the problem more times that I care to admit.

  2. Pry Pry Pry Params Params Params
    These are wonderful tools provided to us by some beautiful big brain angels of mercy. Don't take their hard work for granite because they alone made it possible for me to make it through.

  3. Nested routes make everything better
    I tried to come up with this clean design that 100% separated components because I felt nesting made things looked messy. To an extent, I still feel I am right but I also don't know what i'm talking about. I spent days trying to pull of this "clean code" and only minutes from nesting.

  4. Stay consistent
    This is also a no brainer but apparently I don't have one at all because its a lesson I had to learn again. No need to try and be fancy or just throw something together, take you time and plan out your approach. Oder matters in routing. In addition, tracing your work becomes a lot easier if you stay consistent in how you layout controllers.

Top comments (0)