Notes posted by vikramhimanshu

RSS feed
January 9, 2014 - (v3.2.13)
0 thanks

onChange Event


I’m brand new to ROR and in general server side programing. I’m a iOS developer who is trying to learn ROR.

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,

<div class=“span8”>

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

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

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

{: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 %>