2
也有類似的問題,但我已經過去了,他們都沒有應用。Rails,Devise Invitations 406 STI的不可接受的錯誤
我使用的是Devise和Devise invitations。 Rails 3.2.6。
棘手的是我有兩個用戶模型。用戶和藝術家從用戶繼承的單個表繼承設置。我有兩個邀請控制器允許分別向用戶和藝術家發送邀請。
現在的問題是藝術家無法接受他們的邀請。在表單提交更新密碼後,他們得到了406個不可接受的錯誤。
相關代碼:
路由:
devise_for :users,
:class_name => User,
:controllers => { :invitations => 'user/invitations' }
namespace :artist do
# Special route for devise, artists invitation
devise_scope :user do
resource :invitation, :controller => :invitations, :only => [:create, :new, :update] do
get :accept, :action => :edit
end
end
end
藝術家邀請控制器
class Artist::InvitationsController < Devise::InvitationsController
respond_to :html
# PUT /resource/invitation
def update
self.resource = Artist.accept_invitation!(params[resource_name])
if resource.errors.empty?
resource.pending
flash[:notice] = "Welcome, complete your artist agreement to get started"
sign_in(:user, resource)
respond_with resource, :location => after_accept_path_for(resource)
else
respond_with_navigational(resource){ render :edit }
end
end
end
形式描述。 edit.html.erb。
<%= form_for resource, :as => resource_name, :url => artist_invitation_path(resource_name), :html => { :method => :put } do |f| %>
<%= f.hidden_field :invitation_token %>
<%= f.label :password, class: 'control-label' %>
<%= f.password_field :password, :placeholder => 'Enter a password' %>
<%= f.label :password_confirmation, class: 'control-label' %>
<%= f.password_field :password_confirmation, :placeholder => 'Confirm your password' %>
<%= f.submit "Set my password", :'data-disable-with' => "Hang on..." %>
<% end %>
接受頭
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:236
Content-Type:application/x-www-form-urlencoded
返回
Request URL:http://localhost:3000/artist/invitation.user
Request Method:POST
Status Code:406 Not Acceptable
我能看到的東西,格式必須是因爲在對。用戶最終將響應了。我不能爲我的生活看到爲什麼或在哪裏發生。請讓我知道是否有任何信息我可以幫忙。
我的猜測是'/ artist/invitation.user'來自你放入表單標籤中的url字段。看看生成的表單html,看看是否是這種情況。如果是這樣,嘗試使用表單標記的選項來查看是否有幫助。 – Frost 2012-07-28 15:07:28
謝謝。這導致我孤立了這個變量。 – ScotterC 2012-07-28 21:23:41