Sinatra Routing Exceptions

I want to be able to do the following:

get '/:slug' do haml :page end get '/administration' do haml :admin end 

Is there a way that I can have get '/:slug' do exception for / administration? I understand you can do this with if else:

 get '/:slug' do if params[:slug] == 'administration' haml :admin else haml :page end end 

But this is not a very clear look. Is there a way to have exceptions for routes?

+4
source share
1 answer

Sinatra must respect the order of the routes, so if you first put the route /administration and its corresponding request, get '/:slug' will not be called at all.

+7
source

Source: https://habr.com/ru/post/1304098/


All Articles