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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:42:17+00:00 2026-06-17T01:42:17+00:00

I’m working with a Hobo app using the input_many tag to handle a many-to-many

  • 0

I’m working with a Hobo app using the input_many tag to handle a many-to-many relationship on a form. This puts + and – buttons on the page, and the + adds a new select tag for picking the model on the other side of the relationship. This means that there can be an arbitrary number of select menus with very similar characteristics, distinguished only by an array index, like this:

<select class="input belongs_to data_set_graph" name="graph_pane[data_set_graphs][0][data_set_id]">
[...options...]
</select>
<select class="input belongs_to data_set_graph" name="graph_pane[data_set_graphs][1][data_set_id]">
[...options...]
</select>

N.B. the join of GraphPanes and DataSets is polymorphic (there are many kinds of GraphPanes) so the actual CSS class name varies according to the kind of pane – it could be data_set_a_graph_pane_data_set or data_set_b_graph_pane_data_set.

We’ve been using Capybara 1.1.2 to test this. As long as we’re only associating one DataSet with a GraphPane, we’ve been able to select them with a step definition like this:

included_defs.each do |data_set_name|
  click_button "+"
  select_node = find(:css, '.input-many-item select') # There may be more than one of these?
  select_node.find(:xpath, XPath::HTML.option(data_set_name), :message => "cannot select option with text '#{data_set_name}'").select_option
end

However, now we need to associate two DataSets with a GraphPane, and the find(:css, '.input-many-item select') fails because there are two matching nodes.

It seems to me that if I could just always pick the last one, this would work, but I can’t figure out how to do this with Capybara’s selectors. (I think part of the problem is that it’s not clear to me, in most of the examples I find, whether they refer to the 1.x DSL or the 2.x series.)

Ideas for sorting this out elegantly are welcome.

  • 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-17T01:42:18+00:00Added an answer on June 17, 2026 at 1:42 am

    The answer turns out to be using the “all” finder in Capybara:

    included_defs.each do |data_set_name|
      click_button "+"
      select_node = all(:css, '.input-many-item select').last # There may be more than one of these
      select_node.find(:xpath, XPath::HTML.option(data_set_name), :message => "cannot select option with text '#{data_set_name}'").select_option
    end
    

    all is like find, but it returns an array of matching nodes, so I can use .last and always get the last one.

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

Sidebar

Related Questions

I am using Paperclip to handle profile photo uploads in my app. They upload
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
We're building an app, our first using Rails 3, and we're having to build
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm making a simple page using Google Maps API 3. My first. One marker
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
I want to count how many characters a certain string has in PHP, but
I am using JSon response to parse title,date content and thumbnail images and place

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.