我有一个博客风格的网站,每篇文章下面都有用户登录后通常的'查看''编辑'和'删除'功能。问题是当我点击'删除'它发送给你的链接到“查看”文章页面并且不删除文章。由于删除和视图路径在我的代码中是不同的,但是做同样的事情......不能指出这一点。博客删除操作错误?
class ArticlesController < ApplicationController
before_filter :authenticate_user!, :except => [:index, :show]
# GET /articles
# GET /articles.xml
# display the amount of article on the home page
def index
@articles = Article.published.page(params[:page]).per(6).ordered
respond_to do |format|
format.html # index.html.erb
# format.atom #index.atom.builder
format.xml { render :xml => @articles }
end
end
# GET /articles/1
# GET /articles/1.xml
def show
@article = Article.find(params[:id])
@comment = Comment.new(:article=>@article)
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @article }
end
end
...
/控制器/ articles_controller
# DELETE /articles/1.xml
def destroy
@article = Article.find(params[:id])
authorize! :destroy, @article
@article.destroy
respond_to do |format|
format.html { redirect_to(articles_url) }
format.xml { head :ok }
end
end
end
视图/物品/ _article.html.erb
<div class= "art-links">
<%= link_to 'Read', article %>
<% if can? :update, article %>
| <%= link_to 'Edit', edit_article_path(article) %> |
<% end %>
<% if can? :destroy, article %>
<%= link_to 'Delete', article, :confirm => 'Are you sure?', :method => :delete %>
<% end %>
</div>
<br />
好点 - 我确实在Railscast插曲后面安装了“jquery-rails”gem,我的理解是它删除了prototype.js框架。糖..我如何解决这个问题,所以它再次工作? – ubique 2011-05-17 18:00:13
你在添加gem后运行了'jquery:install'生成器吗? – 2011-05-17 18:15:26
@Austin我在运行软件包安装后运行了(jquery:install)cmd,得到了这个疯狂的错误 - 已经发布了上面的镜头。有什么建议么? – ubique 2011-05-17 18:44:00