小编Vik*_*ets的帖子

Rails 4,嵌套属性,对于ID =的人找不到ID =的标签

Rails 4:我想用标签创建Person

person = Person.new(:name=>Jon', :tags_attributes=>[{:id=>'15', :name=>'some_tag'}])
Run Code Online (Sandbox Code Playgroud)

我的人模型:

class Person < ActiveRecord::Base

  validates :name, presence: true

  belongs_to :user
  has_many :organizations, through: :people_organizations
  has_and_belongs_to_many :tags, join_table: :people_tags

  has_many :phones, as: :phoneable, :dependent => :destroy
  has_many :emails, as: :emaileable, :dependent => :destroy
  has_many :networks, as: :networkable, :dependent => :destroy
  has_many :messengers, as: :messengerable, :dependent => :destroy

  accepts_nested_attributes_for :phones, :emails, :networks, :messengers, allow_destroy: true
  accepts_nested_attributes_for :tags, reject_if: :all_blank

end
Run Code Online (Sandbox Code Playgroud)

我的PeopleController:

  def create
    @person = Person.new(person_params)

    respond_to do |format|
      if @person.save(validate: false)
        format.json { …
Run Code Online (Sandbox Code Playgroud)

nested strong-parameters ruby-on-rails-4

5
推荐指数
1
解决办法
1425
查看次数

AWS Cognito + RubyOnRails在后端获取用户信息.AWS :: CognitoIdentityProvider ::错误:: NotAuthorizedException

我应该将cognito + ruby​​整合到轨道上.

我的用户使用cognito默认登录页面登录,并使用url params重定向到我的页面.

https://development-my-site.auth.us-west-2.amazoncognito.com/oauth2/authorize?client_id=62i222222222222&redirect_uri=https://c3ffec02.ngrok.io/auth/cognito/callback&response_type=token&scope=email+openid+profile

重定向后,我有params

id_token=eyJraWQiOiIyYThzTzY3........
&access_token=eyJraWQiOiJDa0I2NGJsUFJKTWZrNGlV.....
&expires_in=3600
&token_type=Bearer
Run Code Online (Sandbox Code Playgroud)

我应该access_token从url 获取并传递给后端以进行用户验证.

在后端我使用AWS-SDK```

  def client
    @client ||= Aws::CognitoIdentityProvider::Client.new(region: options.aws_region)
  end

  def get_user_info(params)
    client.get_user(access_token: params['access_token'])
  end
Run Code Online (Sandbox Code Playgroud)

```

但结果我有错误 Aws::CognitoIdentityProvider::Errors::NotAuthorizedException (Access Token does not have required scopes):

我应该怎么做获取用户信息?

ruby-on-rails amazon-web-services oauth-2.0 amazon-cognito aws-sdk-ruby

4
推荐指数
1
解决办法
1158
查看次数