I’m trying to use collection select to implement filtering for my page.
The idea is there are a bunch of posts and I want to implement record
filtering for those.

The first collection box would have parameters like “Date”, “Amount”,
“Category” and based on the selection of this a secondary drop down
would appear and allow the user to make a selection. The records on this
page would be then filtered based on both the selection.

I have been trying out many things and have googled a lot on collection
but I have reached a dead end now. I’m pretty new and just started
learning ROR.

You help is much appreciated here.

Thanks in advance.

Note: the code below might be wrong and as of now its not even
compiling… currently it complaints of “remote_function” not defined…

I have a page that looks like this,

<% if @user.spendings.any? %>

    <h3> Spendings (<%= @user.spendings.count  %>)</h3>

    <%= collection_select(:category, :category, Category.all, :id,


{:prompt => 'Select'})%>

<%= collection_select :event, :filterType, Filters.all, :id,

:filterType, {},


  :onchange => remote_function(

    :url => {:action => "updatelevel", :controller => "Spendings",

:id => 1},

    :with => "'level_id='+this.value"



    <ol class="spendings">

      <%= render @spendings %>


    <%= will_paginate @spendings %>

<% end %>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs