Ruby on rails 正在尝试将ajax添加到RoR应用程序

Ruby on rails 正在尝试将ajax添加到RoR应用程序,ruby-on-rails,ajax,debugging,ruby-on-rails-3,Ruby On Rails,Ajax,Debugging,Ruby On Rails 3,尝试将ajax添加到类似Twitter的micropost控制器时,我遇到了一个ActionView::MissingTemplate错误。以下是全部错误: ActionView::MissingTemplate (Missing template microposts/create with {:handlers=>[:rhtml, :erb, :rxml, :builder, :rjs], :locale=>[:en, :en], :formats=>[:js, :html

尝试将ajax添加到类似Twitter的micropost控制器时,我遇到了一个
ActionView::MissingTemplate
错误。以下是全部错误:

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
方法。顺便说一句,第9行是
响应
行:

  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
我做错了什么


更新:我的
视图
文件夹中有.rjs文件。应该在那里吗?文件应该有一个特定的名称吗?当前名为
create.rjs

create.rjs
应位于
app/views/microposts
文件名应为

create.js.erb
然后,在控制器中,必须使用:

respond_to do |format|
  format.js # view create.js.erb
end

要在rails 3中使用RJ,请使用*

原型钢轨

*宝石