in my controller
def elegir
@mercado=Mercado.find(:all)
@empresas=Empresa.find(:first)
respond_to do |format|
format.html {render :layout => false}
end
end
The error message is telling you that you don't have an element with
id muestra_2. Have you checked the html you generate?
I bet you'll find that all your divs are <div id="muestra_i"> (and not
<div id="muestra_1">, <div id="muestra_2">, ..._
Defenitely use a partial if you can. they save readability,
manageability and are just very cool ingeneral.
from docs:
# Renders the same partial with a local variable.
render :partial => "person", :locals => { :name => "david" }
# Renders the partial, making @new_person available through
# the local variable 'person'
render :partial => "person", :object => @new_person
# Renders a collection of the same partial by making each element
# of @winners available through the local variable "person" as it
# builds the complete response.
render :partial => "person", :collection => @winners
# Renders the same collection of partials, but also renders the
# person_divider partial between each person partial.
render :partial => "person", :collection =>
@winners, :spacer_template => "person_divider"
# Renders a collection of partials located in a view subfolder
# outside of our current controller. In this example we will be
# rendering app/views/shared/_note.r(html|xml) Inside the partial
# each element of @new_notes is available as the local var "note".
render :partial => "shared/note", :collection => @new_notes
# Renders the partial with a status code of 500 (internal error).
render :partial => "broken", :status => 500
There are ways to clean this up more (for example, pass @empresas
through :local in the render partial declaration) and I believe some
of the functions I've used will only work this way under Rails 2+.
div_for will automatically create div id's like 'mercado_3', etc.