我有一個博客風格的網站,每篇文章下面都有用戶登錄後通常的'查看''編輯'和'刪除'功能。問題是當我點擊'刪除'它發送給你的鏈接到「查看」文章頁面並且不刪除文章。由於刪除和視圖路徑在我的代碼中是不同的,但是做同樣的事情......不能指出這一點。博客刪除操作錯誤?
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