Ich möchte Taste in Rails-Anwendung zu zerstören, aber es zeigt den Kommentarundefinierte Methoden Links # anzeigen Rails
undefined method `comment_path' for #<#<Class:0x007fe0566264c8>:0x007fe05a5df3f8>
Did you mean? font_path
Während ich nicht font_path haben, und wenn ich dieses Pseudo-Code loszuwerden, die Problem ist weg, aber ich kann den Kommentar nicht zerstören.
Wenn ich das los werde, ist das Problem weg, aber ich kann den Kommentar nicht löschen. Wenn ich das @ -Symbol vor dem Kommentar in "Destroy" setze, wird nicht der Kommentar gelöscht, sondern der Beitrag. Hier ist der vollständige Code:
<%= div_for(comment) do %>
<div class="comments_wrapper clearfix">
<div class="pull-left">
<p class="lead"><%= comment.body %></p>
<p><small>Submitted <strong><%= time_ago_in_words(comment.created_at) %> ago</strong> by <%= comment.user.email %></small></p>
</div>
<div class="btn-group pull-right">
<% if comment.user == current_user -%>
<%= link_to 'Destroy', comment, method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-sm btn-default" %>
<% end %>
</div>
</div>
Das ist mein routes.rb Code
Rails.application.routes.draw do
devise_for :users
resources :links do
member do
put "like", to: "links#upvote"
put "dislike", to: "links#downvote"
end
resources :comments
end
root to: "links#index"
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# # resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
Vielen Dank für Ihre Hilfe!
posten Sie Ihre Routen .. –
@GokulM Ich habe das für Sie aktualisiert. – chronycles