Hi, I've been having a heck of a time trying to get checkboxes for filter options of a search page working. I have a SearchController and views: index, keyword, for the searching part. And I have the Event model, controller and views. The Event model contains the actual search method since I need to search through all Events for the given keyword. What I need to do is somehow get the Event model to know whether or not the checkboxes in the Search view index are checked without using a database. I tried using attr_reader, but it doesn't work. This is what I have now:
class Event < ActiveRecord::Base
attr_accessor :search_streams attr_accessor :search_auds
def self.search(keywords, options = {}, *args)
if @search_streams == "1" ... end
if @search_auds == "1" ... end
end
class SearchController < ApplicationController def index @calendars = Calendar.find(:all) @calendars << default_calendar end
And in the search index view:
<p class="help">Find events that interest you.</p>
<% form_for :event do |f| %> <%= f.check_box :search_streams, {:class => 'check'} %> Search Streams <br /> <%= f.check_box :search_auds, {:class => 'check'} %> Search Audiences <br /> <% end %>
Is it even possible to access the checkboxes from the search index in the Event model? I really need help with this, I'm so confused about checkboxes... I'm not even sure of how to get whether or not checkboxes are even checked!