Radio_button_tag quirkiness


#1

…or my ineptitude?

I found that the following is always checking the last ‘things’ button
regardless of the value of query.table:

People:<%= radio_button_tag(“query”, “table”, “P”) %>
Animals:<%= radio_button_tag(“query”, “table”, “A”) %>
Things:<%= radio_button_tag(“query”, “table”, “T”) %>

But the following works correctly:

People:<%= radio_button(:query, :table, “P”) %>
Animals:<%= radio_button(:query, :table, “A”) %>
Things:<%= radio_button(:query, :table, “T”) %>


#2

dr plutes wrote:

But the following works correctly:

People:<%= radio_button(:query, :table, “P”) %>
Animals:<%= radio_button(:query, :table, “A”) %>
Things:<%= radio_button(:query, :table, “T”) %>

That looks like one of those places that symbols and strings are not
created equal. Don’t worry about it, it’s Rails being a tad quirky :slight_smile:
In general, in Ruby, symbols and strings are very different creatures.
Rails goes through quite a few contortions to make them
interchangeable, but there are a few places that slip through the
cracks…