Maybe you can convince me I don't need such things in Cuba, but with Sinatra I use the url() AKA to() helper method quite a bit. Especially when I am mounting apps with Rack::URLMap. It lets me change the 'mount-point' without breaking the links and redirects spread all over my app. It's the equivalent of Rails' url_for without the overhead of controller classes.
I don't see how you could have such a method in Cuba very easily, given there isn't this concept of fixed top-level mount-points and the SCRIPT_NAME is adjusting all the time. I suppose in your top-level app, you could have some settings like
Maybe you can convince me I don't need such things in Cuba, but with Sinatra I use the
url()
AKAto()
helper method quite a bit. Especially when I am mounting apps with Rack::URLMap. It lets me change the 'mount-point' without breaking the links and redirects spread all over my app. It's the equivalent of Rails'url_for
without the overhead of controller classes.I don't see how you could have such a method in Cuba very easily, given there isn't this concept of fixed top-level mount-points and the
SCRIPT_NAME
is adjusting all the time. I suppose in your top-level app, you could have some settings likeAnd then some helpers that uses these settings like
So then when you decide you have to re-organize or rename the mount-points, you only have to change the strings in one place.
But is there another simple alternative to using full path strings in links and redirects?
@codereading/readers