【发布时间】:2012-05-12 13:14:46
【问题描述】:
我正在尝试按照 rails 入门指南 http://guides.rubyonrails.org/getting_started.html 为我在 rails 中开发的一个小型网站创建一个博客
我已经阅读了许多关于 SO 的类似问题,但我仍然无法弄清楚为什么我在尝试按照指南中所做的那样销毁评论时不断收到错误 The action 'show' could not be found for CommentsController error。
这是我的 html.erb 代码中的链接:
<%= link_to 'Destroy Comment', [comment.post, comment], :confirm => 'Are you sure you want to delete?', :method => :delete %>
我的模板标题有这些行
<%= csrf_meta_tag %>
<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js", "rails", "superfish", "jquery.quicksand", 'slides.min.jquery' %>
我的 gemfile 包含这个:
gem 'jquery-rails'
我还注意到,当我加载带有销毁评论链接的页面时,firebug 控制台中出现此错误:
"NetworkError: 404 Not Found - http://localhost:3000/assets/rails.js"
对于解决此问题的任何帮助表示赞赏。让我知道您是否想要发布其他任何内容。
编辑: 清单文件。
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
Routes.rb
Allthingswebdesign::Application.routes.draw 做
get "about/index"
get "home/index"
get "portfolio/index"
get "contact/index"
post "contact/create"
get "contact/new"
get "posts/index"
get "posts/new"
资源:帖子做 资源:cmets 结束
root :to => 'home#index' 结束
【问题讨论】:
-
在添加 gem 之后安装了 run bundle 吗?
-
是的,我在添加 gem 后运行了 bundle install。
-
如果没有 rails.js 文件,链接将不会被转换为使用 delete 方法,并且确实会路由显示。只是想确认加载此资产是问题
-
如果您使用资产管道,那么您应该使用清单来定义所有 javascript 包含标签。
-
您能否提供有关 rails.js 文件以及资产管道和清单的更多详细信息?我是新来的铁路。 jquery-rails gem 不是包含 rails.js 文件吗?
标签: ruby-on-rails ruby ruby-on-rails-3