Ruby Sinatra路线未被认可
我遇到了一些问题,Sinatra 无法识别我的路线(所有其他路线都工作正常,只是这组特定的 4 条路线)。布局是:在我的 views
中,用户单击与 /all
/inactive
/ 路由相对应的过滤器按钮active
或 /expired
,并且应根据此选择进行过滤。
这是 index.haml
过滤器:
%form{method: 'GET', action: "/showings/all"}
%input#all.btn.btn-md.btn-secondary{type: 'submit', value: 'All'}
%form{method: 'GET', action: "/showings/active"}
%input#active.btn.btn-md.btn-secondary{type: 'submit', value: 'Active'}
%form{method: 'GET', action: "/showings/inactive"}
%input#inactive.btn.btn-md.btn-secondary{type: 'submit', value: 'Inactive'}
%form{method: 'GET', action: "/showings/expired"}
%input#expired.btn.btn-md.btn-secondary{type: 'submit', value: 'Expired'}
%form{method: 'DELETE', action: "/showings/delete", style: "padding-left: 45%"}
%input#delete.btn.btn-md.btn-danger{type: 'submit', value: 'Delete Expired Hosted Screenings'}
但是,在 controllers
文件夹中的 showings_routes.rb
文件中,我尝试了这些路由,但它们从未得到已注册(我已尝试重新启动网络应用程序):
get '/all' do
p "ALL ROUTES"
haml :'showings/index'
end
get '/active' do
p "ACTIVE ROUTES"
haml :'showings/index'
end
get '/inactive' do
p "INACTIVE ROUTES"
haml :'showings/index'
end
get '/expired' do
p "EXPIRED ROUTES"
haml :'showings/index'
end
delete '/delete' do
p "DELETE ROUTES"
redirect '/showings'
end
我计划稍后添加过滤器逻辑,当我单击其中一个按钮或导航到 localhost:3000/showings/all 时,路线不会被识别。我只是很困惑,因为这是一个内置的网络应用程序,所以 showings_routes.rb
文件中的所有其他路由都工作正常(例如 /create
/submit< /code> 等)
当我在应用程序中处理路由时,是否遗漏了什么?
I'm having some issues with Sinatra not recognizing my routes (all other routes work fine, it is just this specific set of 4 routes). The layout is: in my views
, the user clicks on a filter button which corresponds to the route of /all
/inactive
/active
or /expired
, and should filter out based on this selection.
Here is the index.haml
filters:
%form{method: 'GET', action: "/showings/all"}
%input#all.btn.btn-md.btn-secondary{type: 'submit', value: 'All'}
%form{method: 'GET', action: "/showings/active"}
%input#active.btn.btn-md.btn-secondary{type: 'submit', value: 'Active'}
%form{method: 'GET', action: "/showings/inactive"}
%input#inactive.btn.btn-md.btn-secondary{type: 'submit', value: 'Inactive'}
%form{method: 'GET', action: "/showings/expired"}
%input#expired.btn.btn-md.btn-secondary{type: 'submit', value: 'Expired'}
%form{method: 'DELETE', action: "/showings/delete", style: "padding-left: 45%"}
%input#delete.btn.btn-md.btn-danger{type: 'submit', value: 'Delete Expired Hosted Screenings'}
However, in my showings_routes.rb
file in my controllers
folder, I tried these route but they never get registered (I've tried restarting the web app):
get '/all' do
p "ALL ROUTES"
haml :'showings/index'
end
get '/active' do
p "ACTIVE ROUTES"
haml :'showings/index'
end
get '/inactive' do
p "INACTIVE ROUTES"
haml :'showings/index'
end
get '/expired' do
p "EXPIRED ROUTES"
haml :'showings/index'
end
delete '/delete' do
p "DELETE ROUTES"
redirect '/showings'
end
I'm planning on adding the filter logic later, the routes are just not being recognized when I click one of the buttons or navigate to localhost:3000/showings/all
. I'm just confused because this is a built web app, so all the other routes in the showings_routes.rb
file work fine (like /create
/submit
etc.)
Is there a thing that I'm missing when I'm handling my routes here in my application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论