2014-11-06 95 views
0

在我的rails項目中,我想通過ajax打開一個模式框(face box)。我在index.html.erb代碼:缺少js格式的模板

<%= link_to 'Anmelden', fb_login_path, :remote => true %> 

這引發了我的錯誤:

Missing template facebox/fb_login, application/fb_login with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :arb, :coffee]}. Searched in: ...

這是正確的,因爲我的模板是js.erb文件。我讀的地方,我要在我的控制器中添加:

FaceboxController:

def fb_login 
    respond_to do | format | 
     format.js 
    end 
    end 

這樣做,我得到的錯誤:

Started GET "/facebox/fb_login" for 127.0.0.1 at 2014-11-05 18:09:46 +0100 Processing by FaceboxController#fb_login as HTML Completed 406 Not Acceptable in 0ms (ActiveRecord: 0.0ms)

這是奇怪,因爲上週一切工作。同時 - 據我記憶 - 我沒有改變一件事。但現在我得到這個錯誤。

我知道這聽起來很奇怪,但我希望有人能幫助我。

謝謝! 拉爾斯

編輯

此北京時間我fb_login.js.erb碼:

$.facebox('<%= escape_javascript(render :partial => 'devise/sessions/new') %>') 

EDIT 2

這裏是耙路線

fb_login /facebox/fb_login(.:format) facebox#fb_login

和輸出routes.rb:

match '/facebox/fb_login' => 'facebox#fb_login', :as => :fb_login 

或許有助於

+0

請發佈您的'fb_login.js.erb'模板代碼 – RSB 2014-11-06 10:25:09

+0

我編輯了我的文章 – Lars 2014-11-06 11:53:55

+0

沒有創意?我應該發佈一些更多的代碼? – Lars 2014-11-06 17:36:30

回答

0

設置在寶石文件「軌」到「3.2.20」運行「捆綁更新軌」終於爲我工作。