#82 ✓resolved
salamandyr

problem with modifying example

Reported by salamandyr | April 13th, 2009 @ 10:34 PM

hi, i'm trying just a basic example modified from your binarylogic example pages - selecting conditions doesn't restrict by those conditions, and returns all the results in the database - is this a bug?

app/controllers/searches_controller.rb

class SearchesController < ApplicationController
def index @search = Guitar.new_search(params[:search]) @guitars, @guitars_count = @search.all, @search.count end end

app/views/index.html.erb:

<% form_for [@search] do |f| %>

Search guitars
<% f.fields_for @search.conditions do |guitars| %>
  <%= guitars.label :any, "Match ANY or ALL of the conditions" %><br />
  <%= guitars.select :any, [["All", false], ["Any", true]] %><br />
  <br />

  <%= guitars.label :model_keywords %><br />
  <%= guitars.text_field :model_keywords %><br />
  <br />

  <%= guitars.label :color_keywords %><br />
  <%= guitars.text_field :color_keywords %><br />
  <br />

  <%= guitars.label :serial_ends_with %><br />
  <%= guitars.text_field :serial_ends_with %><br />
  <br />

  <%= f.submit "Search" %>
<% end %>
<% end %>

<% if @guitars_count > 0 %>
<%= @guitars_count %> guitars found

<% @guitars.each do |guitar| %> <% end %>
<%= order_by_link :model %> <%= order_by_link :color %> <%= order_by_link [:serial, :model] %>
<%= guitar.model %> <%= guitar.color %> <%= guitar.serial %>



Per page: <%= per_page_select %>

<% if @search.page_count > 1 %>

<%= page_links :spread => 1 %>
<% end %> <% else %>
No guitars were returned <% end %>

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Provides common named scopes and object based searching.

People watching this ticket

Pages