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

  • Home
  • SEARCH
  • 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 8851717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:13:24+00:00 2026-06-14T13:13:24+00:00

I am new to rails and I would like to export a dictionary (of

  • 0

I am new to rails and I would like to export a dictionary (of strings).
At the moment I am using this piece of code

    Competency.order(:competencies).map(&:competencies).uniq!.join(", ")

To generate:

   Build a cage!, Build tha pizza, Demonstrated ability in flying, Demonstrated ability in pizza baking

I would like to export this to csv, however the problem is that it is one array. I would like to create separate strings (comma separated) and displaying each string on a different row. Currently everything is displayed on one row when exporting this to csv.

Any clue how to do this? I created an array of the data because there is a lot of duplicate data and this piece of code is filtering all the duplicates out.

In my controller:

   format.csv { render Competency.order(:competencies).map(&:competencies).uniq!.join(", ") }

I hope anyone could help me, much appreciated.

Edit:

Ideally I would like to fetch all competencies and have an output without duplicates, this is my controller:

    def dictionary
      @competencies = Competency.all

        respond_to do |format|
        format.html { render html: positions_dictionary_path }
        format.csv { render Competency.order(:competencies).map(&:competencies).uniq!.join(", ") }
        format.xls { send_data Competency.order(:competencies).map(&:competencies).uniq!.join(", ") }

      end
    end

Usually in a view file you would do:

      <div>
        <% @posts.each do |competency| %>
          <%= competency.competencies %>
        <% end %>
      </div>

This generates a list of all the competencies, however also the duplicates. My solution was to create an array. However this creates problems when exporting to csv (because I need every output on a different line/row. So my question, how can I generate a list of all the “competencies” without duplicates?

  • 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-14T13:13:25+00:00Added an answer on June 14, 2026 at 1:13 pm

    Rows are not going to be comma separated. They are probable new line terminated. If you want these on separate rows you should maybe try joining them with new lines instead of commas.

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

Sidebar

Related Questions

I am new to Rails. We are using rails 3. I would like to
I am creating a new Rails 3.1 application. I would like this new application
I am new to emacs and I would like to use emacs-rails for editing
Im new to rails and would like to implement authorization and authentication for my
I'm new to rails and would like to use AJAX to update the a
New to rails 3 I would like to create a contact form that people
I am new to rails and I would like to know which is the
I am new to Rails. I have a User model. I would like a
I am using Ruby on Rails 3.0.7 and I would like to install and
I am using Ruby on Rails 3.0.7 and I would like to use check

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.