# Discourse Ruby API testing "Unknown attribute 'auth\_token' for User

**URL:** https://meta.discourse.org/t/discourse-ruby-api-testing-unknown-attribute-auth-token-for-user/75704
**Category:** Bug
**Created:** [December 8, 2017, 8:58pm UTC](https://meta.discourse.org/t/discourse-ruby-api-testing-unknown-attribute-auth-token-for-user/75704 "2017-12-08T20:58:28Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![typeoneerror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/typeoneerror/32/80817_2.png) [@typeoneerror](https://meta.discourse.org/u/typeoneerror)
#### Post date: [December 8, 2017, 8:58pm UTC](https://meta.discourse.org/t/discourse-ruby-api-testing-unknown-attribute-auth-token-for-user/75704/1 "2017-12-08T20:58:28Z")

</div>

I was hoping to use the Discourse API Ruby Gem and replace my SingleSignOn class with the one in there. It looks dated compared to [https://github.com/discourse/discourse/blob/master/lib/single\_sign\_on.rb](https://github.com/discourse/discourse/blob/master/lib/single_sign_on.rb), so I was going to submit a PR to get it up to speed, but I’m stuck on setting up a test environment as noticed in the gem repo:

```plaintext
2. Inside of your discourse directory, run: `bundle exec rake db:api_test_seed`

```

When I do this I get…

```plaintext
~/Dev/discourse (master) $ bundle exec rake db:api_test_seed
Loading test data for discourse_api
rake aborted!
ActiveModel::UnknownAttributeError: unknown attribute 'auth_token' for User.
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:48:in `_assign_attribute'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:40:in `block in _assign_attributes'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:39:in `each'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:39:in `_assign_attributes'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activerecord-5.1.4/lib/active_record/attribute_assignment.rb:26:in `_assign_attributes'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activemodel-5.1.4/lib/active_model/attribute_assignment.rb:33:in `assign_attributes'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activerecord-5.1.4/lib/active_record/core.rb:337:in `initialize'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activerecord-5.1.4/lib/active_record/inheritance.rb:66:in `new'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activerecord-5.1.4/lib/active_record/inheritance.rb:66:in `new'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activerecord-5.1.4/lib/active_record/persistence.rb:33:in `create'
/Users/typeoneerror/Dev/discourse/db/api_test_seeds.rb:1:in `<main>'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/bootsnap-1.0.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `load'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/bootsnap-1.0.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `load'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `block in load'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'
/Users/typeoneerror/Dev/discourse/lib/tasks/db.rake:46:in `block in <main>'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/gems/rake-12.1.0/exe/rake:27:in `<top (required)>'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/bin/ruby_executable_hooks:15:in `eval'
/Users/typeoneerror/.rvm/gems/ruby-2.4.1@discourse/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:api_test_seed
(See full trace by running task with --trace)

```

Probably an old rake task or something? What am I doing incorrectly? Do you recommend that we make our own SingleSignOn class as shown in [Setup DiscourseConnect - Official Single-Sign-On for Discourse (sso)](https://meta.discourse.org/t/official-single-sign-on-for-discourse-sso/13045) or the Ruby Gem?

---

<div class="post-metadata">

### Author: ![typeoneerror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/typeoneerror/32/80817_2.png) [@typeoneerror](https://meta.discourse.org/u/typeoneerror)
#### Post date: [December 8, 2017, 9:01pm UTC](https://meta.discourse.org/t/discourse-ruby-api-testing-unknown-attribute-auth-token-for-user/75704/2 "2017-12-08T21:01:10Z")

</div>

Looks like `auth_token` was an individual property originally and the seeding is still utilizing that instead of a `has_many` relationship. I might be able to fix w a PR if someone can confirm for me!

---

<div class="post-metadata">

### Author: ![typeoneerror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/typeoneerror/32/80817_2.png) [@typeoneerror](https://meta.discourse.org/u/typeoneerror)
#### Post date: [December 8, 2017, 9:33pm UTC](https://meta.discourse.org/t/discourse-ruby-api-testing-unknown-attribute-auth-token-for-user/75704/3 "2017-12-08T21:33:06Z")

</div>

PR #1 [Updates api\_test\_seeds for multiple auth\_token support by typeoneerror · Pull Request #5414 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/5414)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [December 8, 2017, 9:56pm UTC](https://meta.discourse.org/t/discourse-ruby-api-testing-unknown-attribute-auth-token-for-user/75704/4 "2017-12-08T21:56:59Z")

</div>

Merged in thanks heaps! shall I close this?

---

<div class="post-metadata">

### Author: ![typeoneerror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/typeoneerror/32/80817_2.png) [@typeoneerror](https://meta.discourse.org/u/typeoneerror)
#### Post date: [December 8, 2017, 10:12pm UTC](https://meta.discourse.org/t/discourse-ruby-api-testing-unknown-attribute-auth-token-for-user/75704/5 "2017-12-08T22:12:45Z")

</div>

Yes, you can close it, I’ll open a separate PR for the Discourse API.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [December 8, 2017, 10:14pm UTC](https://meta.discourse.org/t/discourse-ruby-api-testing-unknown-attribute-auth-token-for-user/75704/6 "2017-12-08T22:14:12Z")

</div>


