Advertisement
sas2job

Untitled

Aug 28th, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. irb(main):118:0> test2 = Spree.user_class.first
  2. Spree::User Load (16.0ms) SELECT `spree_users`.* FROM `spree_users` WHERE `spree_users`.`deleted_at` IS NULL ORDER BY `spree_users`.`id` ASC LIMIT 1
  3. irb(main):119:0> test2
  4. => #<Spree::User id: 1, email: "admin@example.com", persistence_token: nil, perishable_token: nil, last_request_at: nil, login: "admin@example.com", ship_address_id: nil, bill_address_id: nil, created_at: "2020-08-25 04:14:24", updated_at: "2020-08-25 11:05:30", spree_api_key: "f9e21147d1d6951021a12a31469b0cda5392bfd7fee7c5ef", authentication_token: nil, deleted_at: nil, first_name: "admin", last_name: "admin", photo: nil, phone: "+79050000000">
  5. irb(main):120:0>
  6.  
  7. select_users = Spree::Digital::Subscription.where(ends_at: time_range,renewal: true)
  8. irb(main):121:0> select_users
  9. Spree::Digital::Subscription Load (0.6ms) SELECT `spree_subscriptions`.* FROM `spree_subscriptions` WHERE `spree_subscriptions`.`ends_at` BETWEEN '2020-08-28 16:17:32' AND '2020-08-29 16:17:32' AND `spree_subscriptions`.`renewal` = TRUE LIMIT 11
  10. => #<ActiveRecord::Relation [#<Spree::Digital::Subscription id: 1, user_id: 1, subscription_plan_id: 1, starts_at: "2020-08-25 11:11:28", ends_at: "2020-08-29 16:00:00", renewal: true, created_at: "2020-08-25 11:11:28", updated_at: "2020-08-28 14:41:48">]>
  11.  
  12. irb(main):122:0> test2 = Spree.user_class.joins(:spree_subscriptions)
  13. irb(main):123:0> test2
  14. Traceback (most recent call last):
  15. ActiveRecord::ConfigurationError (Can't join 'Spree::User' to association named 'spree_subscriptions'; perhaps you misspelled it?)
  16. irb(main):124:0>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement