Ruby on rails Rails 5-路由和显示页面未连接

Ruby on rails Rails 5-路由和显示页面未连接,ruby-on-rails,model-view-controller,routes,link-to,Ruby On Rails,Model View Controller,Routes,Link To,我正在尝试为Rails 5中的人员列表设置一个显示页面,但在同步路由时遇到问题 config.route: get '/team', to: 'pages#team' get '/team/:id', to: 'pages#show', as: 'agent' #to get agent_path from rails routes 第页\u控制器: def team @admins = Admin.where(role: :staff) end def show @admins =

我正在尝试为Rails 5中的人员列表设置一个显示页面,但在同步路由时遇到问题

config.route:

get '/team', to: 'pages#team'
get '/team/:id', to: 'pages#show', as: 'agent' #to get agent_path from rails routes
第页\u控制器:

def team
 @admins = Admin.where(role: :staff)
end  

def show
 @admins = Admin.find(params[:id])
end
视图/页面/team.html.erb:

<% @admins.each do |staff| %>
  <div class="team-link__inner">
    <div class="agent-image-team">
     <%= link_to (image_tag(staff.url, class: "team_link") agent_path(staff.id), class: "team-link") %>
    </div>
    <div class="hover-team-info">
      <p><%= staff.name %></p>
    </div>
  </div>
 <% end %>

显示路线用于显示单个对象的信息

def show
 @admin = Admin.find(params[:id])
end
视图应该只显示特定对象属性的信息(show.html.erb)

管理显示页面

基于错误,在图像标记结束括号后缺少逗号

<%= link_to(image_tag(staff.url, class: "team_link"), agent_path(staff.id), class: "team-link") %>

你的链接声明就是问题所在。尝试:

<%= link_to agent_path(staff.id), class: "team-link" do %>
   <%= image_tag staff.url, class: "team_link" %>
   # or
   <img src="#{staff.url}" class="team_link" />
<% end %>

#或

希望它能解决错误

对,也是这样。Rails在索引视图中的这一行有一个更大的问题:如果您可以用以下问题发布您的错误会更容易:
…)agent\u path…
?应该是:
…),代理路径…
?就是这样!为了让css保持稳定,我做了一些安排,但这是我需要的最后一次推动。谢谢
<h1>Admin show page</h1>
<p><%= @admin.name %></p>
<%= link_to(image_tag(staff.url, class: "team_link"), agent_path(staff.id), class: "team-link") %>
<%= link_to agent_path(staff.id), class: "team-link" do %>
   <%= image_tag staff.url, class: "team_link" %>
   # or
   <img src="#{staff.url}" class="team_link" />
<% end %>