我試圖將ajax添加到類似Twitter的微控制器時出現ActionView::MissingTemplate
錯誤。這是完整的錯誤:嘗試添加ajax到RoR應用程序
ActionView::MissingTemplate (Missing template microposts/create with {:handlers=>[:rhtml, :erb, :rxml, :builder, :rjs], :locale=>[:en, :en], :formats=>[:js, :html]} in view paths "/rubyprograms/sample_app/app/views"):
app/controllers/microposts_controller.rb:9:in `create'
這是我的create
方法。 Btw第9行是respond_to
行:
def create
@micropost = current_user.microposts.build(params[:micropost])
if @micropost.save
flash[:success] = "Micropost created!"
respond_to do |format|
format.html { redirect_to root_path }
format.js
end
else
@feed_items = []
render 'pages/home'
end
end
我在做什麼錯了?
更新:我在我的views
文件夾中有我的.rjs文件。那是它應該在哪裏?該文件是否應具有特定名稱?它目前被稱爲create.rjs