…with a little help from our friends.

It’s wonderful to be able to go on Slack and speak to awesome developers instantly who are ready and willing to help. And it’s the best kind of help: not giving out answers but encouraging you to experiment and learn for yourself.

So recently, I was getting hung up on an error that, it later turned out, had to do with my URL routing. I need one of my controllers to be able to access an id from another controller, and I didn’t understand why I was seeing a funny url that looked like this: myurl.com/blah/.79. It turned out that I was trying to pass the id 79 via a place designated for the format (e.g. html), and I wasn’t managing to access it whatever method I tried.

The objects involved here are books and notes. As you might expect, books can have many notes (as in, marginal notes) and notes belong to a single book. So when I’m dealing with notes, I want to know what book I’m in as well.

I was helped to understand that I need to fix my routes so that the resources for the notes are nested within the resources for the books, which will produce urls that look like: /books/:book_id/notes/new(.:format), thus preserving access to the book_id.

But probably the biggest thing I got out of seeking help on Slack was the suggestion to simple play around with routes to learn how they work. It turns out that routing is pretty flexible in rails. You can specify whatever url mappings you want, you can replace id numbers with letters, etc.

As in so many cases, it pays to try things out yourself to answer your own questions before seeking answers on Google.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.