我想用 intercom-rails gem 设置自定义数据属性。在UserController#sign_up
我有intercom_custom_data.user[:sign_up] = true
但没有创建变量。我尝试在其他控制器(TruckController#edit
)中,如果它被创建。
用户控制器.rb
class UserController < ApplicationController
skip_before_filter :check_admin
skip_before_filter :authenticate_user!, except: [:recovery]
skip_before_filter :verify_authenticity_token
def sign_up
...
if user.save
puts current_user.inspect
# <User id: 11, username: "user", email: "user@email.com", encrypted_password: "aebvcbb5c..."
intercom_custom_data.user[:sign_up] = true
end
end
end
卡车控制器.rb
TruckController < ApplicationController
def index
puts current_user.inspect
# <User id: 11, username: "user", email: "user@email.com", encrypted_password: "aebvcbb5c..."
intercom_custom_data.user[:sign_up] = true
end
end