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 8331873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:33:09+00:00 2026-06-09T02:33:09+00:00

I’m using ActiveAdmin and trying to do a as: :select , :collection that isn’t

  • 0

I’m using ActiveAdmin and trying to do a as: :select, :collection that isn’t a multiple select.

My code is:

form do |f|
  f.input :users, :as => :select, :input_html => { :size => 1}, :multiple => false, collection: User.where(role:1), include_blank: false
end

Where this is in /admin/businesses.rb. The relationship is that there is habtm between Users and Businesses. I’ve tried rearranging my options as shown in the github issue. I’ve also looked at a similar stackoverflow question.

However, when I try with the :multiple => false, I get this code generated:

<select id="business_user_ids" multiple="multiple" name="business[user_ids][]" size="1">    
<option value="4">Pilgrim</option>
<option value="5" selected="selected">Mary</option>
<option value="6" selected="selected">Bob</option>
<option value="7">Billy</option>
<option value="8">Ash</option></select>

Note that there are two selected, and the code for multiple is set to multiple. Any one know why this is?

Also, I’m trying to figure out how to display another field as what is selectable.

For example, I have f.inputs :users. is there a way to rename what is shown for :users? Right now, it shows users.name, but I would like users.email.

  • 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-09T02:33:11+00:00Added an answer on June 9, 2026 at 2:33 am

    I just bumped into this problem, too. After a little code tracing I found that it’s duo to the underlying Formtastic lib.

    Formtastic takes precedence of existing reflection (has_many & has_and_belongs_to_many) over the options you pass in to decide it’s multiple or not.

    I think it’s because forcing single selection on a ?-to-many relation will cause some confusions. Just like your data, there are already two selected, what should be shown in a strict single select? But I’ll maybe raise this issue to Formtastic later.

    If you still need that function, you could just monkey patch it by placing the following code at config/initializers/formtastic.rb

    module Formtastic
      module Inputs
        class SelectInput
          def multiple_with_options_fix?
            return false if options[:multiple] === false
            multiple_without_options_fix?
          end
    
          alias_method_chain :multiple?, :options_fix
        end
      end
    end
    

    And for your second question, you just need to add the following code into your model.

    class User < ActiveRecord::Base
      .....
    
      def to_label
        self.email
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm trying to select an H1 element which is the second-child in its group
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.