showアクションを行おうとすると <h2><%= link_to co_member.company_name, :co_detail %></h2>の列に下記のようなエラーが出てしまい、
解決できません。どなたかわかる方おられましたら、教えていただけないでしょうか?
よろしくお願いいたします。
ActionController::UrlGenerationError in Co::Top#index
Showing /vagrant/app/views/co/top/index.html.erb where line #11 raised:
No route matches {:action=>"show", :controller=>"co/detail", :host=>"jobtopaz.example.com"} missing required keys: [:id]
app/views/co/top/index.html.erb
ruby
1<% @title = 'top_page' %> 2 3<%= page_entries_info @co_members %> 4<%= paginate @co_members %> 5 6 <% @co_members.each do |co_member| %> 7<div id="contents"> 8 <div class="left"> 9 <%= image_tag co_member.photo.url(:thumb), width: 200 %> 10 </div> 11 <h2><%= link_to co_member.company_name, :co_detail %></h2> 12 <p><%= co_member.title %></p> 13 <p><%= truncate(co_member.body, length: 80) %> 14 <%= link_to "read more", "" %></p> 15 <br class="leftclear"> 16</div> 17 <% end %> 18 19 <%= paginate @co_members %>
app/controllers/co/details_controller.rb
ruby
1class Co::DetailsController < ApplicationController 2 def show 3 @co_member = CoMember.find(params[:id]) 4 5 end 6end
config/routes.rb
ruby
1Rails.application.routes.draw do 2 config = Rails.application.config.jo 3 4 constraints host: config[:co][:host] do 5 namespace :co, path: config[:co][:path] do 6 root 'top#index' 7 get 'login' => 'sessions#new', as: :login 8 resource :session, only: [ :create, :destroy ] 9 resource :account, except: [ :new, :create, :destroy ] 10 resources :detail 11 end 12end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2016/10/13 06:22