我試圖在編輯帳戶頁面中使用「添加用戶頭像」鏈接爲用戶個人資料添加頭像。「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