0
在我的index.html中,我使用<%=呈現'rates/rate_form'%> 呈現速率表單,並且表單是ajax。內容_rate_form的是:rails3 before_filter導致過濾器鏈暫停爲:驗證呈現或重定向錯誤
`<%= form_for [@image, Rate.new], :remote=>true do |f| %>
<input type="hidden" name="image_id" value="<%= @image.id%>"/>
<button type="submit"> Rate</button>
<% end %>`
在我的價格控制,我定義一個的before_filter,只有在使用中籤可以創建率。 類RatesController <的ApplicationController 的before_filter:身份驗證,:只=>:
def authenticate
redirect_to signin_url unless signed_in?
end
日誌是:
Redirected to http://localhost:3000/signin
Filter chain halted as :authenticate rendered or redirected
Completed 302 Found in 3ms (ActiveRecord: 0.7ms)
Started GET "/signin" for 127.0.0.1 at 2013-04-28 12:36:56 +0300
Processing by SessionsController#new as JS
Rendered sessions/new.html.erb within layouts/application (1.3ms)
User Load (0.9ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1
Rendered sessions/new.html.erb (1.2ms)
Rendered layouts/_nav.html.erb (4.8ms)
Rendered layouts/_search.html.erb (0.6ms)
Rendered layouts/_notice_div.html.erb (0.1ms)
Completed 200 OK in 26ms (Views: 24.3ms | ActiveRecord: 0.9ms)
當我點擊我的sesson_helper文件中創建
def create
@rate=Rate.new(:rate=>1)
respond_to do |format|
if @rate.save
format.html { redirect_to(@rate) }
format.js
end
end
end
速率按鈕,控制檯中出現錯誤:過濾器鏈暫停爲:deny_access呈現或重定向 你有什麼想法如何解決它?非常感謝!
實際上,deny_access函數是:def deny_access redirect_to signin_url除非signed_in? 結束 – user1611237 2013-04-27 17:56:58
......哦,我沒有看到。你可以在重定向調用之前啓動調試器會話嗎?不知何故,signed_in?似乎返回假。 – moritz 2013-04-28 08:57:38
在2013-04-28 12:36:56 +0300 處開始GET「/ signin」for 127.0.0.1#作爲JS處理器處理#新作爲JS 在佈局/應用程序中提交會話/ new.html.erb(1.3ms) 用戶負載(0.9ms)SELECT「users」。* FROM「users」WHERE「users」。「id」IS NULL LIMIT 1 渲染會話/new.html.erb(1.2ms) 渲染布局/ _nav.html.erb (4.8ms) 渲染布局/ _search.html.erb(0.6ms) 渲染布局/ _notice_div.html.erb(0.1ms) 嗨,@moritz,這裏是日誌,我注意到它說「Processing by SessionsController #new as JS「,我認爲它應該是Html,對吧? – user1611237 2013-04-28 09:47:21