使用link_to创建类似时出错

时间:2011-07-19 20:27:06

标签: ruby-on-rails ruby ruby-on-rails-3

当我点击链接时,我收到此错误:

 No route matches {:action=>"show", :controller=>"likes",
 :doweet_id=>2}

这是link_to代码:

 link_to image_tag("/images/friends/thumbs-up.jpg"),  like_path(:doweet_id => doweet.id), :method => :post

在路线中:

  resources :likes

in likes controller:

class LikesController < ApplicationController

  respond_to :html, :js

  def create 
    @like = Like.new(:doweet_id => params[:doweet_id])
    #push(comment)  
    flash[:notice] = "Like successfully created" if @like.save
    respond_with( @like, :layout => !request.xhr? )
  end

end

1 个答案:

答案 0 :(得分:1)

link_to image_tag("/images/friends/thumbs-up.jpg"),  likes_path(:doweet_id => doweet.id), :method => :post, :remote => true