【发布时间】:2015-12-31 00:03:38
【问题描述】:
我正在使用 Padrino,我想从 URL 中取出参数并在 .erb 模板中使用它们。
在我的应用设置中,我有:
get '/testpage/:id' do
userID = params[:id]
render 'test/index'
end
在我的test/ 文件夹中,我有index.html.erb 已成功呈现,用于http://localhost:9000/testpage/hello123 之类的网址。
但是,我尝试在页面上打印params[:userID]:
<%= @userID %>
页面的其余部分呈现良好,但在任何地方都找不到 hello123。当我尝试<%= userID %> 我得到undefined local variable or method `userID' for #<stuff>
我在这里错过了什么?
【问题讨论】: