Home Rails 5 - routes and show page not hooking up
Reply: 0

Rails 5 - routes and show page not hooking up

user1899
1#
user1899 Published in April 22, 2018, 3:07 am

I am trying to set up a show page for a list of people in Rails 5, but having trouble getting the routes to sync.

config.route:

get '/team', to: 'pages#team'
get '/team/:id', to: 'pages#show', as: 'agent' #to get agent_path from rails routes

page_controller:

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

def show
 @admins = Admin.find(params[:id])
end

views/pages/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 %>

views/pages/show.html.erb: (sample to confirm routes)

<h1>Admin show page</h1>
<%@admins.each do |staff| %>
  <p><% staff.name %></p>
<% end %>

I've tried connecting my show pages up in a number of different ways, but keep getting errors when I try to set up my link in the index (team) view. What am I doing wrong?

errors are:

.../app/views/pages/team.html.erb:26: syntax error, unexpected tIDENTIFIER, expecting ')' class: "team_link") agent_path(staff.id), class: "team-link" ^ 
.../app/views/pages/team.html.erb:26: syntax error, unexpected ',', expecting ')' m_link") agent_path(staff.id), class: "team-link") );@output ^ 
.../app/views/pages/team.html.erb:26: syntax error, unexpected ')', expecting keyword_end aff.id), class: "team-link") );@output_buffer.safe_append=' ^ 
.../app/views/pages/team.html.erb:60: syntax error, unexpected keyword_ensure, expecting end-of-input ensure ^
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.311659 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO