Ruby on Rails
Tuesday, June 16, 2015
Arthur,
It hasn't been all that long since I've used 3.2, but I *think* you're using the wrong syntax. Please look at http://apidock.com/rails/v3.2.8/ActionView/Helpers/UrlHelper/link_to that shows the link_to method at that time.
Also, look at the html that is generated for the view and see if you can tell what's happening.
I wish I could be of more help...
Tamara
On Mon, Jun 15, 2015 at 10:51 PM, Rafael Belo <rafaelrpbelo@gmail.com> wrote:
Post your route.rb plz.
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#createjobs 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#worldTo view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8bf2de99-6019-4f0f-998c-75bc845ece68%40googlegroups.com.--
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.
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/CAHUC_t_6FKWgtuZwaPS3ALzs2kBT6CMj6EM7iciwPMtKqX%3D7ww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment