Will_paginate error a partir de la primera pagina

Perdón por el titulo pero no sabia bien como expresar lo que me sucede.
Tengo instalado will_paginate y funciona bien, el problema es con mi
codigo, hago una secuencia con el codigo:

ELCONTROLLER
class ExpedienteController < ApplicationController
layout ‘standard’

def list
persona = Persona.find_by_identificador(params[:i])
@tipo = Tipo.find_by_id(params[:tipo_id])

if params[:i] == nil #en la entrada inicial a la pagina
  #@expedientes_filtered = Expediente.find(:all, :conditions =>

{:tipo_id => params[:tipo_id]})
@expedientes_filtered = Expediente.paginate :page =>
params[:page], :per_page => 2, :conditions => {:tipo_id =>
params[:tipo_id]}
else
if persona == nil #cuando no existe o no se pone nada
#@expedientes_filtered = Expediente.find(:all, :conditions => {
:id => -1})
@expedientes_filtered = Expediente.paginate :page =>
params[:page], :per_page => 2,:conditions => { :id => -1}
else
#@expedientes_filtered = Expediente.find(:all, :conditions =>
[“persona_id = ? and tipo_id = ?” , persona.id, params[:tipo_id]])
@expedientes_filtered = Expediente.paginate :page =>
params[:page], :per_page => 3, :conditions => [“persona_id = ? and
tipo_id = ?” , persona.id, params[:tipo_id]]
end
end

if request.xhr?
  render :partial => "expediente", :layout => false
end

end

LIST VIEW

Buscar Expediente de: <%= @tipo.tipo %>

<% form_tag do %>
DNI Solicitante :
<%= text_field_tag(:i, params[:i], :size => 10 ) %>
<%= submit_tag “Buscar” %>
<%= hidden_field_tag(:tipo_id, params[:tipo_id], :value =>
@tipo.id) %>

<% end %>

<%= render :partial => "expediente" %>

<% form_tag :action => ‘new’ do %>

  <%= submit_tag "Nuevo expediente" %>
  <%= hidden_field_tag(:tipo_id, params[:tipo_id], :value =>

@tipo.id) %>
<% end %>

PARTIAL VIEW

<% @expedientes_filtered.each do |exp| %>
  <tr class="<%= cycle("even","odd") %>">
    <td><small> <%= link_to 'editar', {:action => "show", :id =>

exp.id, :tipo_id => @tipo.id} %>









<% end %>
Nº Expediente Estado Descripcion Fecha Solicitud Fecha Concesión Solicitante
<%= will_paginate @expedientes_filtered %>
<%= link_to ‘borrar’, {:action => “delete”, :id =>
exp.id},
:confirm => “¿Esta seguro que quiere borrar este
expediente?” %>
<%= link_to exp.numero_exp, {:controller => ‘historial’,
:action => “list”, :expediente_id => exp.id, :tipo_id => @tipo.id}
%>
<%= exp.estado.estado %> <%= exp.descripcion %> <%= exp.fecha_solicitud %> <%= exp.fecha_concesion %> <%= exp.persona.nombre %>

Os comento, cuando no filtro por ninguna persona, el will_paginate
funciona bien, y me voy moviendo entre las paginas sin problemas, PERO
si filtro por una persona, la carga inicial funciona y me sale la
primera pagina y el numero de las siguientes, pero al pinchar en alguna
de ellas me dice este error:

NoMethodError in Expediente#list

Showing app/views/expediente/list.html.erb where line #1 raised:

You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.tipo

Extracted source (around line #1):

1:

Buscar Expediente de: <%= @tipo.tipo %>


2:
3: <% form_tag do %>
4: DNI Solicitante :

RAILS_ROOT: C:/DATOS/JAVIER/PROFESIONAL/ruby/GdA_RoR
Application Trace | Framework Trace | Full Trace

C:/DATOS/JAVIER/PROFESIONAL/ruby/GdA_RoR/app/views/expediente/list.html.erb:1:in
_run_erb_app47views47expediente47list46html46erb' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/renderable.rb:34:insend’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/renderable.rb:34:in
render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:301:inwith_template’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/renderable.rb:30:in
render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/template.rb:199:inrender_template’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:260:in
render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:343:in_render_with_layout’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:257:in
render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1246:inrender_for_file’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:941:in
render_without_benchmark' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:51:inrender’
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in
ms' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:10:inrealtime’
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in
ms' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:51:inrender’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1322:in
default_render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1328:inperform_action_without_filters’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:617:in
call_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:610:inperform_action_without_benchmark’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:68:in
perform_action_without_rescue' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:inms’
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:10:in
realtime' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:inms’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:68:in
perform_action_without_rescue' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/rescue.rb:160:inperform_action_without_flash’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/flash.rb:146:in
perform_action' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:527:insend’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:527:in
process_without_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:606:inprocess’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:391:in
process' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:386:incall’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/routing/route_set.rb:434:in
call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:88:indispatch’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:111:in
_call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:82:ininitialize’
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:29:in
call' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:29:incall’
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in
cache' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:9:incache’
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:28:in
call' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:incall’
C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/head.rb:9:in call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:incall’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/params_parser.rb:15:in
call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/session/cookie_store.rb:93:incall’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/reloader.rb:29:in
call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/failsafe.rb:26:incall’
C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:insynchronize’
C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:106:incall’
C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/rack/static.rb:31:in
call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:46:incall’
C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in
each' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:incall’
C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/rack/log_tailer.rb:17:in
call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/content_length.rb:13:incall’
C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/chunked.rb:15:in
call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/mongrel.rb:61:inprocess’
C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:159:in
process_client' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:ineach’
C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:in
process_client' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:inrun’
C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in
initialize' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:innew’
C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in
run' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:ininitialize’
C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in
new' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:inrun’
C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/mongrel.rb:34:in
run' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/commands/server.rb:111 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require’
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require’
script/server:3

C:/DATOS/JAVIER/PROFESIONAL/ruby/GdA_RoR/app/views/expediente/list.html.erb:1:in
_run_erb_app47views47expediente47list46html46erb' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/renderable.rb:34:insend’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/renderable.rb:34:in
render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:301:inwith_template’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/renderable.rb:30:in
render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/template.rb:199:inrender_template’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:260:in
render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:343:in_render_with_layout’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:257:in
render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1246:inrender_for_file’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:941:in
render_without_benchmark' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:51:inrender’
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in
ms' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:10:inrealtime’
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in
ms' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:51:inrender’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1322:in
default_render' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1328:inperform_action_without_filters’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:617:in
call_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:610:inperform_action_without_benchmark’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:68:in
perform_action_without_rescue' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:inms’
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:10:in
realtime' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:inms’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:68:in
perform_action_without_rescue' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/rescue.rb:160:inperform_action_without_flash’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/flash.rb:146:in
perform_action' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:527:insend’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:527:in
process_without_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:606:inprocess’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:391:in
process' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:386:incall’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/routing/route_set.rb:434:in
call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:88:indispatch’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:111:in
_call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:82:ininitialize’
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:29:in
call' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:29:incall’
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in
cache' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:9:incache’
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:28:in
call' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:incall’
C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/head.rb:9:in call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:incall’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/params_parser.rb:15:in
call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/session/cookie_store.rb:93:incall’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/reloader.rb:29:in
call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/failsafe.rb:26:incall’
C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:insynchronize’
C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in call' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:106:incall’
C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/rack/static.rb:31:in
call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:46:incall’
C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in
each' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:incall’
C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/rack/log_tailer.rb:17:in
call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/content_length.rb:13:incall’
C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/chunked.rb:15:in
call' C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/mongrel.rb:61:inprocess’
C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:159:in
process_client' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:ineach’
C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:in
process_client' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:inrun’
C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in
initialize' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:innew’
C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in
run' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:ininitialize’
C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in
new' C:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:inrun’
C:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/mongrel.rb:34:in
run' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/commands/server.rb:111 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require’
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require’
script/server:3

Request

Parameters:

{“page”=>“2”}

Show session dump


Response

Headers:

{“Content-Type”=>“text/html”,
“Cache-Control”=>“no-cache”}

En definitiva que no encuentra la variable @tipo

Alguna sugerencia por favor!!

Javier M. wrote:

Perdón por el titulo pero no sabia bien como expresar lo que me sucede.
Tengo instalado will_paginate y funciona bien, el problema es con mi
codigo, hago una secuencia con el codigo:

…

Request

Parameters:

{“page”=>“2”}

Show session dump


Response

Headers:

{“Content-Type”=>“text/html”,
“Cache-Control”=>“no-cache”}

En definitiva que no encuentra la variable @tipo

Alguna sugerencia por favor!!

Una pregunta…

Supongo que en el controlador tienes un método “index” que es al que se
llaman cuando “no hay filtros” y todo funciona bien. Luego, cuando
incorporas el filtro y llamas a “list”, es cuando el will_paginate no
funciona… es correcto?

Y una observación. El error que obtienes es porque cuando se llama al
método “list” del controlador, no se le envía el parámetro “tipo_id” con
lo que “@tipo_id” se evalúa a NIL y te falla en la vista cuando se
intenta evaluar “@tipo.tipo”.
Podrías intentar en controlador algo como:

@tipo = (params[:tipo_id].nil? ? <valor_por_defecto> :
Tipo.find_by_id(params[:tipo_id]) )

Un Saludo…

Hola Juan, el controller tiene distintas condiciones según los
parametros que le llegan, así cuando hay filtro pasa por el ultimo else

else
@expedientes_filtered = Expediente.paginate :page =>
params[:page], :per_page => 3, :conditions => [“persona_id = ? and
tipo_id = ?” , persona.id, params[:tipo_id]]

Lo que intento en la vista list una cabecera donde se puede filtrar y es
el partial la que refresco con los datos, pero se ve que el parametro
donde llevo la variable @tipo no se pasa correctamente.

Adjunto unas capturas donde se ve la aplicación funcionando.
Gracias por tu tiempo.

Javier M. wrote:

Hola Juan, el controller tiene distintas condiciones según los
parametros que le llegan, así cuando hay filtro pasa por el ultimo else

else
@expedientes_filtered = Expediente.paginate :page =>
params[:page], :per_page => 3, :conditions => [“persona_id = ? and
tipo_id = ?” , persona.id, params[:tipo_id]]

Lo que intento en la vista list una cabecera donde se puede filtrar y es
el partial la que refresco con los datos, pero se ve que el parametro
donde llevo la variable @tipo no se pasa correctamente.

Adjunto unas capturas donde se ve la aplicación funcionando.
Gracias por tu tiempo.

No hay de que Javier.

Por lo que he visto en los pantallazos, parece que después del primer
filtrado, cuando pones el DNI, pierdes el parámetro tipo_id en la URL y
esto es lo que luego provoca el fallo… puede ser???

Un Saludo…

Es totalmente correcto.

La primera vez funciona porque paso el parametro tipo_id, pero despues
form_tag llama otra vez a list del controller, y ese a su vez sola a la
partial. En fin, cuando no tengo will_paginate funciona porque ya tengo
los expedientes que quiero mostrar, pero parece que al moverme de
pagina, will_paginate refresca toda la view y ya no existe el parametro
tipo_id.

Podria ser una solución pasar en el form_tag como parametro de la acción
list el valor “tipo_id”, eso como se puede hacer??

Thanks a lot.

Hola prueba haciendo esto:

<%= will_paginate @expedientes_filtered, params => {:tipo_id => ‘tu
variable’} %>

Gracias Carlos, lo he probado “con gran emoción” pero sigue apareciendo
el mismo error. De todas formas, voy aprendiendo con vuestras
aportaciones.

Creo que al final quitaré la vista partial y haré siempre llamadas como
la incial cuando entro por primera vez que parece que funciona.

Muchas gracias de nuevo.

Carlos T. wrote:
Hola prueba haciendo esto:

<%= will_paginate @expedientes_filtered, params => {:tipo_id =>
@tipo.id} %>

Disculpa no se como editar el post pero asi deberia ser segun como lo
tienes en tu controller y view…

espero que te funcione…
Saludos

Hola pues. No sé exactamente que me quieres decir. Mi idea es que el
will_paginate solamente me paginara el “partial”, así creo que lo tenia
antes de paginar, no tengo tadavia mucha idea de como realmente
funciona.
Gracias

Javier M. wrote:

Gracias Carlos, lo he probado “con gran emoción” pero sigue apareciendo
el mismo error. De todas formas, voy aprendiendo con vuestras
aportaciones.

Creo que al final quitaré la vista partial y haré siempre llamadas como
la incial cuando entro por primera vez que parece que funciona.

Muchas gracias de nuevo.

OK pero quieres paginar con javascript… que solo actualice el
partial???

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs