Over a million developers have joined DZone.

Cucumber Useful Step Definition (based On WebRat)

DZone's Guide to

Cucumber Useful Step Definition (based On WebRat)

Free Resource
In this tutorial (http://www.ultrasaurus.com/sarahblog/2008/12/rails-2-day-4-rcov-and-more-behavior-driven-development/), you can learn how to do an action to a specific element in a table, finding the row where it is.
Well, I improved the technique so you can press a button, follow a link, choose a radio button, or check/uncheck a checkbox within the row describing a particular element, finding it by any of its attributes (id, name, caption, ...).

This code is assuming that the "trs" of your tables are made like this : 
I haven't used the dom_id thing because I can't get it to work, but if it works for you it's no big deal to change my code a bit.
And of course, you can adapt your within css selector to your needs.

And well, ok, this won't work if you can find more than 1 element matching the value for a given attribute

When /^I (press|follow|check|uncheck|choose) "([^\"]*)" for (.*) whose (.*) is "([^\"]*)"$/ do |action, whatyouclick, class_name, var_name, value|
  unless var_name == "id" then
    id = eval("\"#{class_name}\".classify.constantize.find_by_#{var_name}(\"#{value}\").id.to_s")
    id = value
  within("tr[id=row_#{class_name}_#{id}]") do
    case action
      when "press"
      when "follow"
      when "check"
      when "uncheck"
      when "choose"

Use : 

When I go to the products page
And I press "Delete" for product whose name is "An awesome product"
Then I should see "Product An awesome product deleted"

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}