Radio buttons form in ruby on rails

Hi there!

I m using this form:

<%= form_for(:usage, :url=> {:action =>‘getResults’}) do |f| %>
Select search criteria :

<%= f.radio_button :filter, 'uni'%> <span 

style=“font-size:15px;”>For
Unicast only


<%= f.radio_button :filter, ‘multi’ %> For Multicasts only


<%= f.radio_button :filter, ‘month’ %> Current Month


<%= f.radio_button :filter, ‘date’ %> On
this date:



<%= f.date_select(:date,:order=>[:day,:month,:year])%>


<%= link_to ‘Search’, {:action=>“getResults”}, :remote => true,
:submit%>
<% end %>

and in controller I have:
def getResults
if params[:filter] == ‘uni’

 @results = Multicasts.where(:sms_voice => 'sms')
end

if params[:filter] =='multi'
  @results = Multicasts.where(:when => 'im')
end

if params[:filter] =='month'
   @results = Multicasts.where('extract(month  from datetime) = ?',

MONTH(date))
end

render :new_results

end

Is this a correct way to read info from radio buttons.
Please help, it is not working. Is the syntax correct?

On Sat, Jun 15, 2013 at 4:50 AM, @ddy [email protected]
wrote:

Is this a correct way to read info from radio buttons.
Please help, it is not working. Is the syntax correct?

It’s horrible markup and very un-Ruby/Rails-ish code, but the key
point is: what EXACTLY do you mean by “not working”?

Is your controller getting the params you expect or not? Is the value
of @results not what you expect for a given input?

What is the problem?


Hassan S. ------------------------ [email protected]
http://about.me/hassanschroeder
twitter: @hassan