だから私はリンクに私のコントローラーのメソッドを検索させてからパス/trials/my_playsのカスタムページにリダイレクトさせようとしています
「app/controllers / trails_controller.rb:48:in`show'」に「id=my_playsのTrailが見つかりませんでした」というエラーが表示されます。
ルート:
match '/trails/my_plays', :to => "trails#my_plays", :as => :my_plays
リンク:
<%= link_to "Your Trails", trails_my_plays_path %>
コントローラ:
def show
@trail = Trail.find(params[:id]) #48
@member = Member.find(current_user.member_id)
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @trail }
end
end
def my_plays
@trails = Trail.all # once status is working, need to change to where(:publish => true)
@follower = Play.where(:member_id => current_user.member_id)
@member = Member.find(current_user.member_id)
@followed = [] #all trails followed by current user
@follows = [] #the play record for that trail
@trails.each do |trail|
if @follower.count > 0
@follower.each do |followr|
if (followr.trail_id == trail.id)
@followed << trail
@follows << followr
end
end
end
end
respond_to do |format|
format.html { redirect_to "trails/my_plays" }
end
end