同様の質問がありますが、私はそれらを調べましたが、どれも適用されませんでした。
私はDeviseとDevise の招待状を使用しています。レール 3.2.6.
難しいのは、2 つのユーザー モデルがあることです。ユーザーと、アーティストがユーザーから継承する単一テーブル継承セットアップ。ユーザーとアーティストの両方に招待状を個別に送信できるように、2 つの招待状コントローラーがあります。
現在の問題は、アーティストが招待を受け入れることができないことです。パスワードを更新するためにフォームを送信すると、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
その .user を最後に追加する応答のために、フォーマットの何かがオフになっている必要があることがわかります。なぜ、どこでそれが起こっているのか、一生わからない。私が省略した情報があれば教えてください。