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 Error
> No 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 <http://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 < ApplicationController*
> *  def create*
> * @job = Job.find(params[:job_id])*
> * @comment = @job.comments.build(params[:comment])*
> * if @comment.save*
> *  flash[:notice] = "Comment was created with success!"*
> * else*
> *  flash[:alert] = "Please fill in all fields to create a comment."*
> * end*
> * redirect_to @job*
> *  end*
>
> *  def destroy*
> * @comment = Comment.find(params[:id])*
> * @comment.destroy*
> * redirect_to @comment.job, notice: "Comment destroyed with success."*
> *  end*
> * end*
>
> *rake routes:*
> *           root        /                                jobs#premium*
> *companies_login GET    /companies/login(.:format)       login#new*
> *               POST   /companies/login(.:format)       login#create*
> *     companies POST   /companies(.:format)             companies#create*
> *   new_company GET    /companies/new(.:format)         companies#new*
> *  job_comments POST   /jobs/:job_id/comments(.:format) comments#create*
> *          jobs GET    /jobs(.:format)                  jobs#index*
> *               POST   /jobs(.:format)                  jobs#create*
> *       new_job GET    /jobs/new(.:format)              jobs#new*
> *      edit_job GET    /jobs/:id/edit(.:format)         jobs#edit*
> *           job GET    /jobs/:id(.:format)              jobs#show*
> *               PUT    /jobs/:id(.:format)              jobs#update*
> *               DELETE /jobs/:id(.:format)              jobs#destroy*
> *       comment DELETE /comments/:id(.:format)          comments#destroy*
> *   hello_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+unsubscr...@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.

Reply via email to