備忘録
■
gem 'devise', '~> 3.5.2'
gem 'devise_invitable', '~> 1.5.2'
$ bundle install
■
$ rails g devise_invitable:install
insert config/initializers/devise.rb
create config/locales/devise_invitable.en.yml
$ rails g devise_invitable User
insert app/models/user.rb
create db/migrate/20160113012429_devise_invitable_add_to_users.rb
$ rake db:migrate
■修正
#修正
class User < ActiveRecord::Base
devise :invitable, :invite_for => 2.weeks
end
#追加
class ApplicationController < ActionController::Base
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:invite) << :username
devise_parameter_sanitizer.for(:accept_invitation) << :username
end
end
for(:invite) 招待メールを送る時
for(:accept_invitation) 招待メールからアカウント情報を登録する時
$ rails g devise_invitable:views
views/devise/invitations
<%= f.text_field :username %>