Replies: 3 comments 1 reply
-
I didn't test, but I'm guessing your problem is with |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply. I think you're pointing me in the right direction. I removed the autoloaders and just did Dir["routes/**/*.rb"].each do |route_file|
require_relative route_file
end ... and changed the directory structure a bit to: ... and the routes are working like I expect. So this points me to something with the autoloader that I'm not doing right. I'll keep poking at it. Thanks for your help! |
Beta Was this translation helpful? Give feedback.
-
Hi @sumwatt , i tested with roda-sequel-stack with routes directory structure: ├── routes
│ ├── apitest
│ │ └── products.rb
│ ├── apitest.rb
│ └── prefix1.rb # cat routes/apitest.rb
class MyApp
hash_branch("apitest") do |r|
r.is do
r.get do
'APITEST'
end
end
r.hash_branches
end
end # cat routes/apitest/products.rb
class MyApp
hash_branch '/apitest', 'products' do |r|
r.is do
r.get do
'PRODUCTS'
end
end
end
end I've added this additional autoload_hash_branch_dir('/apitest', './routes/apitest') |
Beta Was this translation helpful? Give feedback.
-
I'm a little stumped and think the answer will be more obvious than I expect. I'm using a slightly modified version of the Roda-Sequel template and modeled my initial routing based on the prefix1 file.
My default route
/
is pointing to root, no issues loading the pageI added a directory in the routes
./routes/apitest
I added two files to the routes directory,
apitest.rb
andproducts.rb
I modified
app.rb
to autoload the new directory:apitest.rb:
products.rb:
/apitest
works fine, but/apitest/products
does not appear to get loaded/routed (404). I've checked the console and can seeapitest.rb
getting Unloaded/loaded, butproducts.rb
does not. I've gone through the documentation and not sure if I'm just overlooking something simple or not. I tried to model my routes similar to those in the Mastering Roda guide but not quite sure if that was the right track. I'd appreciate any pointers!Beta Was this translation helpful? Give feedback.
All reactions