我试图在编辑帐户页面中使用“添加用户头像”链接为用户个人资料添加头像。“Template is missing”错误使用jQuery与Rails
这是avatars_controller.rb:
def new
@avatar = Avatar.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @avatar }
format.js
end
end
def create
@avatar = @user.avatars.create(params[:avatar])
respond_to do |format|
if @avatar.save
format.html { redirect_to(edit_account_path, :notice => 'Avatar was successfully created.') }
format.xml { render :xml => @avatar, :status => :created, :location => @avatar }
format.js
else
format.html { render :action => "new" }
format.xml { render :xml => @avatar.errors, :status => :unprocessable_entity }
format.js
end
end
end
这是我的链接:
<%= link_to "add a new avatar", new_avatar_path%>
路线:
resources :avatars
resources :users do
resources :avatars
end
的意见/化身/ create.js.erb:
alert('whoaaa!!!')
我使用的铁轨3.0.9和获得:
模板丢失
缺少模板化身/新与{:处理器=> [:ERB,:RJS,:建设者, “/ home/ugur/rails_projects/deneme/app/views”中查看路径 :rhtml,:rxml],:formats => [:html],:locale => [:en,:en]/home/ugur/rails_projects/deneme/app/views“, ”/ home/ugur/rails_projects/deneme/flag_promotions/app/views“, ”/home/ugur/.rvm/gems/ruby-1.9.2- p180/gems/spree-0.60.1/app/views“, “/home/ugur/.rvm/gems/ruby-1.9.2-p180/gems/spree_sample-0.60.1/app/views”, “/home/ugur/.rvm/gems/ruby-1.9.2 -p180/gems/spree_promo-0.60.1/app/views“, ”/home/ugur/.rvm/gems/ruby-1.9.2-p180/gems/spree_dash-0.60.1/app/views“, “/home/ugur/.rvm/gems/ruby-1.9.2-p180/gems/spree_api-0.60.1/app/views”, “/home/ugur/.rvm/gems/ruby-1.9.2- p180/gems/spree_auth-0.60.1/app/views“, ”/home/ugur/.rvm/gems/ruby-1.9.2-p180/gems/devise-1.3.3/app/views“, ” /home/ugur/.rvm/gems/ruby-1.9.2-p180/gems/spree_core-0.60.1/app/views“
我即将发疯。请帮忙。
你有一个 '编辑' 的方法?您链接到edit_avatar_path。不要create_avatar_path – Bjoernsen