Combo Select Filter Data

Hi, this is my second post ( sorry for my language )

need yours helps with my problem.
i need filter my model by an option in a Combo select

i thing, “i should be” with observe_field and render partial, but i have
a problem, when past to the second page, the application give me an
error. about ID

thx for your helps!

David,

Could you post the code that you are using as well as the error message
that it’s returning?

David navarrete David wrote:

Hi, this is my second post ( sorry for my language )

need yours helps with my problem.
i need filter my model by an option in a Combo select

i thing, “i should be” with observe_field and render partial, but i have
a problem, when past to the second page, the application give me an
error. about ID

thx for your helps!

*** controller **
def filtro
if !params[:filtro][:campo].nil?
tipo_filtro = params[:filtro][:campo]
@inmobiliaria = Inmobiliaria.find(params[:id])
proyecto = @inmobiliaria.proyectos_inmobiliarios.find(:all,
:conditions => [‘tipo_propiedad_id = ?’,tipo_filtro])
end
@proyectos = proyecto.paginate :page => params[:page], :per_page =>
10
@numero_proyectos = proyecto.size
render :partial => “resultado_inmobiliaria”, :layout => false,
:object => @proyectos
end


*** show **
<% form_for ‘filtro’, :url => {:action => :filtro, :id => params[:id]}
do |f| %>
<%= f.select :campo,
@tipos_propiedades.collect {|p| [ p.descripcion, p.id ] },{
:prompt => ‘Seleccione Filtro’}, {:onchange => “submit();”} %>
<%= f.submit “asd”%>

<% end %>

<%= render :action => "resultado_inmobiliaria" %>
** show **

thx

ups the error

You have a nil object when you didn’t expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]

try:

if params[:filtro] && !params[:filtro][:campo].nil?

or

if (params[:filtro][:campo] rescue false)

if there’s no params[:filtro], the chained call to [:campo] will cause
that error.

On Aug 27, 5:48 pm, David navarrete David <rails-mailing-l…@andreas-