Ruby on Rails
Monday, June 15, 2015
Post your route.rb plz.
Em segunda-feira, 15 de junho de 2015 03:25:54 UTC-3, Arthur Flores Duarte escreveu:
-- Em segunda-feira, 15 de junho de 2015 03:25:54 UTC-3, Arthur Flores Duarte escreveu:
Hello,I am a newbie with Rails and I am having a problem with my study application (Rails 3.2.6), when using Destroy links, I get the following message:Routing ErrorNo route matches [GET] "/comments/2"I can see that the Destroy link are calling a GET command instead of a delete method.I've searched a lot about this problem, but couln't find the reason, hope anyone can help me._comment.html.erb:<h4><%= comment.name %> said:</h4><%= simple_format comment.body %>Sent <%= time_ago_in_words comment.created_at %> ago<%= link_to "Destroy", comment_path(comment), method: :delete , :data => { :confirm => "Are you sure?"} %>comments_controller.rb:class CommentsController < ApplicationControllerdef create@job = Job.find(params[:job_id])@comment = @job.comments.build(params[:comment]) if @comment.saveflash[:notice] = "Comment was created with success!"elseflash[:alert] = "Please fill in all fields to create a comment."endredirect_to @jobenddef destroy@comment = Comment.find(params[:id])@comment.destroyredirect_to @comment.job, notice: "Comment destroyed with success."endendrake routes:root / jobs#premiumcompanies_login GET /companies/login(.:format) login#newPOST /companies/login(.:format) login#createcompanies POST /companies(.:format) companies#createnew_company GET /companies/new(.:format) companies#newjob_comments POST /jobs/:job_id/comments(.:format) comments#create jobs GET /jobs(.:format) jobs#indexPOST /jobs(.:format) jobs#createnew_job GET /jobs/new(.:format) jobs#newedit_job GET /jobs/:id/edit(.:format) jobs#editjob GET /jobs/:id(.:format) jobs#showPUT /jobs/:id(.:format) jobs#updateDELETE /jobs/:id(.:format) jobs#destroycomment DELETE /comments/:id(.:format) comments#destroyhello_world GET /hello/world(.:format) hello#world
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8bf2de99-6019-4f0f-998c-75bc845ece68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment