繼Michael Hartl的Rails教程不斷構建我們的示例應用程序,並且目前沒有在MicropostsController中定義'show',我們應該在MicropostsController或其他位置插入什麼代碼在我們的MVC框架中解決這個錯誤?Unknown action對於MicropostsController無法找到動作'show'
當我們點擊'刪除'飼料中的micropost時,我們得到「未知的操作'找不到'MicropostsController'的操作'錯誤。
class MicropostsController < ApplicationController
before_filter :authenticate, :only => [:create, :destroy]
def create
@micropost = current_user.microposts.build(params[:micropost])
if @micropost.save
flash[:success] = "Micropost created!"
redirect_to root_path
else
@feed_items = []
render 'pages/home'
end
end
def destroy
@micropost.destroy
redirect_back_or root_path
end
end