views:

10

answers:

1

I have a form with a checkboxes:

-form_tag filter_path(@page.permalink), :method => 'get' do |f|
  -ftype.producers.each do |producer|
    =check_box_tag "producers[]", producer.id, false        
    =label_tag producer.title
    %br
  =submit_tag 'Сортувати', :name => nil

When I send a request, it sends a hash params with an array of producers.Link then looks like that:

'/pages/:page_id/filter?producers[]=4&producers[]=5'

And I want to make it look that:

'/pages/:pages_id/filter?producers=4,5'

Please help

A: 

It shouldn't be a problem, since ?producers[]=4&producers[]=5 will be converted by the framework into params[:producers] array with value [4, 5].
Thus, you already have an array and you don't even have to parse anything.

But if your really want to submit two input values in one parameter, you'd have to employ some javascript. By default, if you have in html form two inputs with the same name, two independent values will be submitted (like in sample url you provided).
So, it's not a Rails question, it's html and javascript question.

Nikita Rybak
Никит, с js это сделать легко) а вот без него. Хэш параметров никак нельзя вправить?_)
Paul Samchuk
а всё) терь дошло)
Paul Samchuk