I have a simple RESTful search scaffold that finds data in a separate
model and controller.
<h1>New search</h1>
<% form_for(@search) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :category_id %><br />
<%= f.collection_select :category_id, Category.all, :id, :name,
:include_blank => true %>
</p>
<p>
Age Range<br />
<%= f.text_field :minimum_age, :size => 3 %> -
<%= f.text_field :maximum_age, :size => 3 %>
</p>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
I would like to require at least one parameter in the search, be it a
selected category, a minimum age, or a maximum age.
Sean S. wrote:
I have a simple RESTful search scaffold that finds data in a separate
model and controller.
<h1>New search</h1>
>
> <% form_for(@search) do |f| %>
> <%= f.error_messages %>
>
> <p>
> <%= f.label :category_id %><br />
> <%= f.collection_select :category_id, Category.all, :id, :name,
> :include_blank => true %>
> </p>
> <p>
> Age Range<br />
> <%= f.text_field :minimum_age, :size => 3 %> -
> <%= f.text_field :maximum_age, :size => 3 %>
> </p>
>
> <p>
> <%= f.submit 'Create' %>
> </p>
> <% end %>
I would like to require at least one parameter in the search, be it a
selected category, a minimum age, or a maximum age.
Then write a custom validation method.
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]