def lista_faculdade
teste = params[:teste] @faculdade_teste = Curso.find(:all).select do |student|
student.faculdade_id = teste
end
if I try to do it manually (with /cursos/lista_faculdade?teste=3 for
example it works
all I need to know is how to pas the parameter from the select to the
href link
Thanks in advance! =*
Yes, look into observe_field in the API, and you could easily write a
small RJS template which replaced the link with one with the
appropriately inserted value.
Julian.
Learn Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) VIDEO #3
OUT APRIL 6 http://sensei.zenunit.com/
def lista_faculdade
teste = params[:teste] @faculdade_teste = Curso.find(:all).select do |student|
student.faculdade_id = teste
end
You should probably be using Curso.find_by_faculdade_id(teste) as this
will put the searching at the database level (this is what databases
are good at), and not force Rails to load the entire dataset into
memory to only then filter it back using Ruby’s select iterator.
Julian.
Learn Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) VIDEO #3
OUT APRIL 6 http://sensei.zenunit.com/
You should probably be using Curso.find_by_faculdade_id(teste) as this
will put the searching at the database level (this is what databases
are good at), and not force Rails to load the entire dataset into
memory to only then filter it back using Ruby’s select iterator.
thanks i will be studying now and see how far I can get !
def lista_faculdade
teste = params[‘search_text’] @faculdade_teste = Curso.find(:all).select do |curso|
curso.nome_curso = teste
end @curso_pages, @cursos = paginate_collection @faculdade_teste,
:per_page => 10
end
def show @curso = Curso.find(params[:id])
end
but it’s not finding, instead it’s changing the name of all cursos …
Can someone tell me what am I doing wrong ?
You should probably be using Curso.find_by_faculdade_id(teste) as this
will put the searching at the database level (this is what databases
are good at), and not force Rails to load the entire dataset into
memory to only then filter it back using Ruby’s select iterator.
thanks i will be studying now and see how far I can get !
On 4 Apr 2008, at 16:07, Laura Laizer smith wrote:
def lista_faculdade
teste = params[‘search_text’] @faculdade_teste = Curso.find(:all).select do |curso|
curso.nome_curso = teste
I suspect you want curso.nome_curso == teste, otherwise as you note
you will just be assigning (and since you are assigning non null
values you are effectively selecting them all)
On 4 Apr 2008, at 16:07, Laura Laizer smith wrote:
def lista_faculdade
teste = params[‘search_text’] @faculdade_teste = Curso.find(:all).select do |curso|
curso.nome_curso = teste
I suspect you want curso.nome_curso == teste, otherwise as you note
you will just be assigning (and since you are assigning non null
values you are effectively selecting them all)
Fred
Half of my problems are solved
I can do search now
but if I try Math for instance it opens 4 frames inside the frame of app
to then do the math search
the same number of letter I type the same frames it open inside the
application I think I am doing something very stupid But I dont know
what …