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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:39:52+00:00 2026-05-23T01:39:52+00:00

I have been struggling with what I perceive to be a simple problem: Working

  • 0

I have been struggling with what I perceive to be a simple problem:

Working in Rails 3.0.8 with the simple_form 1.4 gem.

I have two models, owners and owner_types;

class Owner < ActiveRecord::Base
  belongs_to :own_type
  attr_accessible :name, :own_type_id
end

class OwnerType < ActiveRecord::Base
  has_many :owners
  attr_accessible :name, :subtype_name
end

In my the _form partial of the Owner view, I want to have a select box that displays both the name and subtype_name of the owner_type association.
….something like this: Owner Type: [name | subtype_name] eg. [Government | Federal]; [Government | Municipal]

My view now contains: app/views/owners/_form.html.erb

<%= simple_form_for @owner do |f| %>
  <%= f.error_messages %>
  <%= f.input :name %>
  <%= f.association :owner_type, :include_blank => false %>
  <%= f.button :submit %>
<% end %>

…the f.association only list the owner_type.name field by default. How do you specify different fields, or in my case two fields?

All help is appreciated; thanks in advance.

DJ

  • 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-05-23T01:39:53+00:00Added an answer on May 23, 2026 at 1:39 am

    You’ll have to use the :label_method option for this.

    <%= f.association :owner_type, :include_blank => false, :label_method => lambda { |owner| "#{owner.name} | #{owner.subtype_name}" } %>
    

    or, if you define a select_label method on the owner’s class, you can do

    <%= f.association :owner_type, :include_blank => false, :label_method => :select_label %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been struggling to get a simple autocomplete working with my Rails app
I have been struggling trying to test a super simple EJB project in netbeans.
This may seem like a very simple question, but I have been struggling with
I have been struggling with the best way to make sure that the certain
I have for the last several years been struggling to understand why the Internet
I have been working on a web services related project for about the last
I have been working with Visual Studio (WinForm and ASP.NET applications using mostly C#)
Have been struggling with Javascript closure for a while trying to wrap brain around
I have been struggling with this for some time now scanning the net for
I have been struggling with choosing a methodology for creating a RESTful API with

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.