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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:11:38+00:00 2026-05-31T19:11:38+00:00

I am using formtastic to render a form for a object of a model

  • 0

I am using formtastic to render a form for a object of a model that has a HABTM relationship with another model.

I am doing this to render a list of checkboxes:

<%= f.input :classes, :as => :check_boxes, :collection => UserClass.all %>

And yes, it renders all the checkboxes and at the right side it shows the object name, something like this. So I have something like this:

[x] #<UserClass:0x000000087e4958>

How can I change that? I want to show the class name and description…

Thank you.

  • 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-31T19:11:39+00:00Added an answer on May 31, 2026 at 7:11 pm

    Use the :member_label option:

    <%= f.input :classes, :as => :check_boxes,
        :collection => UserClass.all, :member_label => :name %>
    

    (Assuming your UserClass has a name attribute, for example). If your label comes from multiple fields, you can pass a Proc. For example (if your UserClass has first_name and last_name attributes):

    <%= f.input :classes, :as => :check_boxes,
        :collection => UserClass.all,
        :member_label => Proc.new { |u| "#{u.first_name} #{u.last_name}" } %>
    

    The above is for Formtastic version 2.x. For the 1.2-stable branch, it works the same (you can pass in a method name or proc) but the option is called :label_method. Example:

    <%= f.input :classes, :as => :check_boxes,
        :collection => UserClass.all, :label_method => :name %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ActiveAdmin and Formtastic. I have an invoice form that has a drop
I am trying to set up a form using Formtastic which has a drop
I am using acts_as_commentable. This is how the Model has comments added to it:
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C#, I need a class called User that has a username, password, active
I have rails 3.1.3 and formtastic 2.0.2. I'm using the most basic form you
Using MVC2 I have an AJAX form which is posting to a bound model.
I am trying to setup a simple form using formtastic but running into a
I have a user model with a HABTM relationship to groups. I do not
I'm using formtastic & formtastic_cocoon to created a nested form. All seems to be

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.