#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| %>

<legend>Search guitars</legend>

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

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



Per page: <%= per_page_select %>

<% if @search.page_count > 1 %>

<div class="pages"><%= page_links :spread => 1 %></div>

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