Q:

Rails + Capybara: Selecting select option using HTML class?

My select looks like this:
    <select id="product_products_colors_attributes_0_variants_attributes_1401459162565_size_id" class="size_select" name="product[products_colors_attributes][0][variants_attributes][1401459162565][size_id]">
        <option value="1">XS</option>
        <option value="2">S</option>
        <option value="3">M</option>
        <option value="4">L</option>
        <option value="5">XL</option>
        <option value="6">One Size</option>
    </select>

The thing is that the 1401459162565 part is random (comes from the nested_form gem). How would I select M from this select dropdown using the class (or ID or any way that works with the random number)?

A:

I'm fairly new to Capybara, but as I understand it, you can select for embedded elements (by class) like this: 
  within('.select_box') do
    click_on "Option"
  end

There is also the select method:
select('Option', :from => 'Select Box')

