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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:27:23+00:00 2026-05-27T15:27:23+00:00

I’m getting the following error: undefined method `id’ for #<Array:0x00000101ff0b70> On this line: <%=

  • 0

I’m getting the following error:

undefined method `id' for #<Array:0x00000101ff0b70>

On this line:

<%= collection_select(:staff, :id, @staff, :id, :name, options ={:prompt => "-Select a staff member"}) %>

Here’s the action method:

def new
  @treatments = Treatment.all
  @clients = Client.all
  @staff = Staff.all

  @booking = Booking.new

  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @booking }
  end
end

Now, I know what you’re thinking, have you got a has_many through relationship etc., but actually the set up at the moment (because it’s in its first iterations) is very simple, and in fact mimics that of other types on the same page which work just fine. On the same page I have this:

<%= collection_select(:client, :id, @clients, :id, :name, options ={:prompt => "-Select a client"}) %>

And in fact, the model is precisely the same except with a different name. Both only have an ID and a name field. In fact, even the relationship in the model is the precisely the same. There’s a booking, a client, and a staff member. A client has_many :bookings, and a “staff” has_many :bookings. The only different I can really see is that I’m using inflections.rb to do the following

ActiveSupport::Inflector.inflections do |inflect|
    inflect.uncountable "staff"
end

Any ideas why I can’t get this to work?

EDIT

Honestly, I think it has to do with belongs_to :staff in booking.rb model. This is something to do with pluralisation IMO.

EDIT EDIT

To be more specific, the following form works fine:

<%= form_for(Booking.new) do |f| %>
        <div class="field">
            <%= f.label :treatment %><br />
            <%= collection_select(:treatment, :id, Treatment.all, :id, :name, options ={:prompt => "-Select a treatment"}) %>
          </div>
          <div class="field">
            <%= f.label :client %><br />
            <%= collection_select(:client, :id, Client.all, :id, :name, options ={:prompt => "-Select a client"}) %>
          </div>
          <div class="field">
            <%= f.label :staff %><br />
            <%= collection_select(:staff, :id, Staff.all, :id, :name, options ={:prompt => "-Select a staff member"}) %>
          </div>
          <div class="actions">
            <%= f.submit %>
          </div>
<% end %>

But the following form does not:

<%= form_for([:admin, @booking]) do |f| %>
  <% if @booking.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@booking.errors.count, "error") %> prohibited this booking from being saved:</h2>

      <ul>
      <% @booking.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :treatment %><br />
    <%= collection_select(:treatment, :id, @treatments, :id, :name, options ={:prompt => "-Select a treatment"}) %>
  </div>
  <div class="field">
    <%= f.label :client %><br />
    <%= collection_select(:client, :id, @clients, :id, :name, options ={:prompt => "-Select a client"}) %>
  </div>
  <div class="field">
    <%= f.label :staff %><br />
    <%= collection_select(:staff, :id, @staff, :id, :name, options ={:prompt => "-Select a staff member"}) %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

The @staff variable is simply generated in the controller action by doing @staff = Staff.all

Any explanation?

  • 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-27T15:27:23+00:00Added an answer on May 27, 2026 at 3:27 pm

    This was a strange issue, something I should’ve spotted earlier.

    <div class="field">
        <%= f.label :treatment %><br />
        <%= collection_select(:booking, :treatment_id, @treatments, :id, :name, options ={:prompt => "-Select a treatment-"}) %>
      </div>
      <div class="field">
        <%= f.label :client %><br />
        <%= collection_select(:booking, :client_id, @clients, :id, :name, options ={:prompt => "-Select a client-"}) %>
      </div>
      <div class="field">
        <%= f.label :staff %><br />
        <%= collection_select(:booking, :staff_id, @staff, :id, :name, options ={:prompt => "-Select a staff member-"}) %>
      </div>
    

    The collection_select helpers needed to be specified for the booking. For some reason I’d just got muddled up as I’ve done this many-a-time before. Hey presto, it now works. Why the error didn’t complain about the second collection_select I don’t know.

    If you do encounter the error I specified, it’s probably because you’ve got multiple helpers trying to resolve the same thing. I’ve not seen this posted anywhere else on the interwebs, but it’s fixed.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I have this code to decode numeric html entities to the UTF8 equivalent character.
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.