最近这个问题(截至我上一次代码推送)开始发生在一个页面上,该页面在当前服务器和rails版本(5.0.0.1)上运行了一年。我随机得到以下错误,但是a)路线确实存在,我一直使用它成功,并且b)如果我刷新页面(有时需要几次)然后加载。换句话说,似乎找不到路线的失败只是暂时的。此外,它似乎只是在我从详细信息页面返回后发生(虽然这不是100%验证)。也就是说,我加载了一个包含下面标记的列表页面,然后我点击进入一个详细页面,然后我点击返回列表,并在刚刚刚刚出现的页面上得到错误!有没有其他人经历过这个?我很容易相信我做错了什么,但不确定要看什么,因为路由是合法的。 提前致谢, 伊恩
ActionView::Template::Error (No route matches {:action=>"membership_confirmation", :controller=>"members", :id=>488}):
19: <% if p.member && @editable %>
20: <%= link_to raw("<span class=\"glyphicon glyphicon-usd\"></span> Add Payment"), new_payment_path(:pid => p.id), :class => "btn btn-primary person-add-payment new msg-trigger", :title => "Record a payment" %>
21: <% last_sent = p.member.membership_notice_sent_at ? '(last sent at ' + p.member.membership_notice_sent_at.strftime('%-m/%-d/%Y') + ') ' : '' %>
22: <%= link_to raw("<span class=\"glyphicon glyphicon-envelope\"></span> Memb. Letter"), {:controller => "members", :action => "membership_confirmation", :id => p.member.id}, {:class => "btn btn-primary ajaxify new msg-trigger", :title => "Send Confirmation #{last_sent}", :target => "_send", :data => {:confirm => "This will send an email message to #{p.email} #{last_sent}- do you want to continue?"}} %>
23: <% last_sent = p.member.renewal_notice_sent_at ? '(last sent at ' + p.member.renewal_notice_sent_at.strftime('%-m/%-d/%Y') + ') ' : '' %>
24: <%= link_to raw("<span class=\"glyphicon glyphicon-envelope\"></span> Renewal Msg."), {:controller => "members", :action => "renewal_message", :id => p.member.id}, {:class => "btn btn-primary ajaxify new msg-trigger", :title => "Send Renewal Message #{last_sent}", :target => "_send", :data => {:confirm => "This will send an email message to #{p.email} #{last_sent}- do you want to continue?"}} %>
25: <% else %>
app/views/people/_list.html.erb:22:
这是完整的_list.html.erb:
<table class="table table-bordered table-striped responsive-utilities">
<thead>
<tr>
<th>Name</th>
<th>Member No.</th>
<th>Membership Status</th>
<th>Expiration</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% people.each do |p| %>
<tr>
<td><%= link_to p.full_name, {:controller => "people", :action =>@editable ? "edit" : "show", :id => p.id}, {:class => "btn btn-secondary new msg-trigger", :title => "#{p.email} ~ #{p.full_address(' ~ ')} ~ #{p.phone} ~ #{p.note}"} %></td>
<td><%= p.member ? p.member.id.to_s.rjust(4, '0') : "" %></td>
<td><%= p.membership_status() %></td>
<td><%= p.member ? p.member.expires_at : "" %></th>
<td>
<% if p.member && @editable %>
<%= link_to raw("<span class=\"glyphicon glyphicon-usd\"></span> Add Payment"), new_payment_path(:pid => p.id), :class => "btn btn-primary person-add-payment new msg-trigger", :title => "Record a payment" %>
<% last_sent = p.member.membership_notice_sent_at ? '(last sent at ' + p.member.membership_notice_sent_at.strftime('%-m/%-d/%Y') + ') ' : '' %>
<%= link_to raw("<span class=\"glyphicon glyphicon-envelope\"></span> Memb. Letter"), {:controller => "members", :action => "membership_confirmation", :id => p.member.id}, {:class => "btn btn-primary ajaxify new msg-trigger", :title => "Send Confirmation #{last_sent}", :target => "_send", :data => {:confirm => "This will send an email message to #{p.email} #{last_sent}- do you want to continue?"}} %>
<% last_sent = p.member.renewal_notice_sent_at ? '(last sent at ' + p.member.renewal_notice_sent_at.strftime('%-m/%-d/%Y') + ') ' : '' %>
<%= link_to raw("<span class=\"glyphicon glyphicon-envelope\"></span> Renewal Msg."), {:controller => "members", :action => "renewal_message", :id => p.member.id}, {:class => "btn btn-primary ajaxify new msg-trigger", :title => "Send Renewal Message #{last_sent}", :target => "_send", :data => {:confirm => "This will send an email message to #{p.email} #{last_sent}- do you want to continue?"}} %>
<% else %>
<%= link_to raw("<span class=\"glyphicon glyphicon-user\"></span> View"), {:controller => "people", :action => "show", :id => p.id}, {:class => "btn btn-primary", :title => "View Details"} %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<div class="bja_pagination">
<%= will_paginate people, :page_links => true %>
</div>
以下是routes.rb的相关部分:
get "members/renewal_message"
get "members/membership_confirmation"
resources :members
这是rake路线的相关输出:
members_renewal_message GET /members/renewal_message(.:format) members#renewal_message
members_membership_confirmation GET /members/membership_confirmation(.:format) members#membership_confirmation
members GET /members(.:format) members#index
POST /members(.:format) members#create
new_member GET /members/new(.:format) members#new
edit_member GET /members/:id/edit(.:format) members#edit
member GET /members/:id(.:format) members#show
PATCH /members/:id(.:format) members#update
PUT /members/:id(.:format) members#update
DELETE /members/:id(.:format) members#destroy
答案 0 :(得分:0)
唉,我是个白痴。当然,我错过了路线上的id。我不知道为什么它有时会起作用,有时候也不会 - 它似乎永远不会起作用。但它已经像这样多年来一直在堵塞!
- NOPE,事实证明它仍然是一个持续存在的问题。没有人有任何想法或类似的经历?
答案 1 :(得分:0)
尝试:
get "members/renewal_message", to: "members#renwal_message"
get "members/membership_confirmation", to: "members#membership_confirmation"
然后确保您的MembersController中具有“ renwal_message”和“ membership_confirmation”这两种方法。