我想添加一个点击div时会呈现部分的ajax。路由到控制器中的自定义动作
此链接:
<h1 id="comments_viewall"><%= link_to "View All", videos_update_comments_path, remote: true%></h1>
我在视频控制器中的自定义方法:
def update_comments
puts "hello"
end
这些路由这样:
get 'videos/update_comments'
不过,我得到此错误:
GET http://localhost:3000/videos/update_comments 404 (Not Found)
Started GET "/videos/update_comments" for 127.0.0.1 at 2014-05-05 13:49:02 -0400
Processing by VideosController#show as JS
Parameters: {"id"=>"update_comments"}
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
in show
Video Load (0.1ms) SELECT "videos".* FROM "videos" WHERE "videos"."id" = ? LIMIT 1 [["id", "update_comments"]]
Completed 404 Not Found in 2ms
ActiveRecord::RecordNotFound (Couldn't find Video with id=update_comments):
app/controllers/videos_controller.rb:94:in `show'
我跟着什么一堆堆栈溢出的问题告诉我这样做,但它仍然没有工作..
安置自己的'show'方法和'耙routes'输出定义的路由。 – Pavan
@vicli我的答案是否解决了您的问题?让我知道结果和查询,如果有的话。 –