我有两个观看次数$0
和quotation.html.erb
。我已正确设置calculate.html.erb
。当从quotation.html.erb
中的表单正确选择下拉菜单时,将从tints
实体检索数据。然后,它将通过呈现视图quotation.html.erb
这就是我对generate.html.erb
tints_controller.rb
现在我正在尝试创建一个页面def calculator
render 'calculator'
end
def quotation
render 'quotation'
end
def generate
// a lot of formulas here
// @measurements will get the measurement from tint entity
if current_page?(:controller => 'tints', :action => 'quotation') //this is my question
@measurements_front = @measurements.front
@measurements_side = @measurements.side
@measurements_rear = @measurements.rear
@measurements_roof = @measurements.roof
else
@measurements_front = params[:front]
@measurements_side = params[:side]
@measurements_rear = params[:rear]
@measurements_roof = params[:roof]
end
end
,供用户在calculate.html.erb
中输入值,而不是从下拉菜单中选择可用数据。用户将手动输入值(如整数)(正面,侧面,背面,屋顶)并提交表单以从视图text_field
所以这是我的问题。我正在尝试使用generate.html.erb
帮助程序查看用户所在的页面。如果用户位于current_page?
,则会从表中获取quotation.html.erb
。如果用户位于@measurements
,则会获得calculate.html.erb
。
我尝试了几种方法,我仍然收到错误:front, :side, :rear: roof
current_page?' undefined method
current_page?`仍然存在于Rails 5中,或者我们必须自己定义它?
另外,我的. Does
设置如下。
routes.rb