Ruby on rails 未初始化常量{“控制器名称”}控制器
我正在尝试在Rails视图中创建一个新页面 我的观点是:histories/index.html.erb 我的控制器是:process_controller.rb 我正在尝试创建的新页面是:历史(付费) 在my routes.rb中,我有:Ruby on rails 未初始化常量{“控制器名称”}控制器,ruby-on-rails,ruby,activerecord,Ruby On Rails,Ruby,Activerecord,我正在尝试在Rails视图中创建一个新页面 我的观点是:histories/index.html.erb 我的控制器是:process_controller.rb 我正在尝试创建的新页面是:历史(付费) 在my routes.rb中,我有: get "process/histories_paid_out" => "process/histories_paid_out", :as => "histories_paid_out" def histories_paid_out()
get "process/histories_paid_out" => "process/histories_paid_out", :as => "histories_paid_out"
def histories_paid_out()
payments = Payments.all
end
在我的process_controller.rb中,我有:
get "process/histories_paid_out" => "process/histories_paid_out", :as => "histories_paid_out"
def histories_paid_out()
payments = Payments.all
end
最后,我在我的视图中调用控制器,如下所示:
<% @histories.each do |history| %>
<%= link_to 'View paid out payments', histories_paid_out_path() %>
<% end %>
但当我点击查看付费支付链接时,我的Rails应用程序给了我以下错误:
怎么了?这太奇怪了,因为我认为我的配置和设置已经正确了。您应该编写模型的单一版本。试试这个:
def histories_paid_out()
payments = Payment.all
end
您还需要在某个地方定义histories变量
最后,除非您将范围改为@payments,否则您的视图中不会显示付款。您的模型通常是单数,而不是复数。请尝试付款。所有付款均无可能的副本。另外,我认为你的问题标题有错误。