Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7896745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:58:25+00:00 2026-06-03T07:58:25+00:00

I have a test spec where I use the following line of code to

  • 0

I have a test spec where I use the following line of code to assign 3 variables to session tokens within my table:

@auth_token, @auth2_token, @auth3_token = Session.limit(3).map(&:token) 

I now wish to assign 3 variables as a role classes from my Roles table which isn’t restricted to one attribute only but the whole class. I have tried the following but it doesnt seem to be working:

@role1, @role2, @role3 = Role.limit(3).map

Can this be achieved? Any pointers would be greatly appreciated !!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:58:26+00:00Added an answer on June 3, 2026 at 7:58 am

    It works for the auth tokens because map converts the relation object into an array which then gets assigned to the variables. For the roles just calling map returns an enumerable and not an array.

    You can just call to_a directly on the relation object returned by the limit call in order to convert it to an array.

    @role1, @role2, @role3 = Role.limit(3).to_a

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following spec to test controller method: context #create do it should redirect
I have the following XML example: <?xml version=1.0 encoding=UTF-8?> <OpenSearchDescription xmlns=http://a9.com/-/spec/opensearch/1.1/ xmlns:custom=http://example.com/opensearchextensions/1.0/> <ShortName>Test</ShortName> <Description>Testing....</Description>
I have a Rails app and I am trying to test it. I use
I have some specs, written in RSpec, that test various models. I use Factory
I have made use of the following JPA implementations: Hibernate, Toplink, OpenJPA Each of
I have tried to use IIS 7 (as included in Windows 7) to test
I have a selenium test that looks like require 'spec_helper' driver = Selenium::WebDriver.for :firefox
I have Test controller and Test agent installed on a virtual machine VM1. Test
I am creating a traceability matrix for PRD. I have test case _id which
I have this test slider http://jsfiddle.net/dUyLY/2/ In Chrome it works nice, but in firefox

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.