I write an application using Roda. I have a nested router like this:
route 'chats' do |r|
env['warden'].authenticate!
r.is do
@current_user = env['warden'].user
r.get do
# code is here
end
r.post do
# code is here
end
end
r.on :String do |chat_id|
r.is 'messages' do
# code is here
r.get do
# code is here
end
r.post do
# code is here
end
end
end
end
I want to divide one big code-block into two routes like this:
route 'chats' do |r|
# code is here
end
route 'chats/:chat_id/messages' do |r, chat_id|
# code is here
end
Please, help. How to do it right?