If Param not set


#1

Hello all, I’m developing an application which allows users to browse
items for sale…

Using the url localhost:3000/browse/by_type/2 (2 is the id of the
category they are in)

Displays the information I want, however localhost:3000/browse/by_type/
will display an error page (becuase the id param is not set)

in my by_type.rhtml view, how to i check to see if the param is set? and
if not display a message?

Also similar question: I have a Property model where I use
@properties = find(:all, :condition[“type_id = ?”, @param[‘id’]])

How do I display a “no items found message” if @properties is empty (ie:
no products for that category)

Thanks!


#2

Justin J. wrote:

in my by_type.rhtml view, how to i check to see if the param is set? and
if not display a message?

<% if params[:id].nil? %>
Message
<% end %>

Also similar question: I have a Property model where I use
@properties = find(:all, :condition[“type_id = ?”, @param[‘id’]])

How do I display a “no items found message” if @properties is empty (ie:
no products for that category)

<% if @properties.empty? %>
Yes, it really is this easy
<% end %>