I had a beginner’s question. I am testing the create action on my
controller. I wanted to fetch the ID parameter of the newly created
object, so that I can make some assertions on it.
But I can’t seem to find an elegant way of doing that. Of course, might
create action redirects. That means that @response.redirect_url is
something like “/show/8”. So I could pluck the number off that, but that
seems too brittle, since if I change my routing, that would no longer
work. I was wondering if there was a way to call routing on the
redirect_url, so that I could then fetch the ID from the parameters
hash. That wouldn’t be brittle at all. But I can’t seem to find any
documentation for routing, and peeking into the class, I’m not sure what
the entry points are.
perhaps there’s a much easier way of doing all this.