Hi, I want to know how I can pass the following parameters ... I have faculdade: id, name curso : id, faculdade_id and the following code #view <%= select(:curso, :faculdade_id , Faculdade.find(:all).collect {|c| [c.nome, c.id] }) %> </p> <th><a href="curso/lista_faculdade?teste="+:faculdade_id> Preço do Curso</a> </th> controller 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! =* -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 3 Apr 2008, at 18:35, Laura Laizer smith wrote:> > Hi, I want to know how I can pass the following parameters ... > I have > faculdade: id, name > curso : id, faculdade_id > > and the following code > > #view > > <%= select(:curso, :faculdade_id , Faculdade.find(:all).collect {|c| > [c.nome, c.id] }) %> </p> > > <th><a href="curso/lista_faculdade?teste="+:faculdade_id> Preço > do Curso</a> </th> > > controllerYou''ll need to use some javascript to do that, unless you use a form (you can always style the button to look like what you want). Fred> > > 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! =* > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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/ On 04/04/2008, at 5:45 AM, Frederick Cheung wrote:> > > On 3 Apr 2008, at 18:35, Laura Laizer smith wrote: > >> >> Hi, I want to know how I can pass the following parameters ... >> I have >> faculdade: id, name >> curso : id, faculdade_id >> >> and the following code >> >> #view >> >> <%= select(:curso, :faculdade_id , Faculdade.find(:all).collect {|c| >> [c.nome, c.id] }) %> </p> >> >> <th><a href="curso/lista_faculdade?teste="+:faculdade_id> >> Preço >> do Curso</a> </th> >> >> controller > > You''ll need to use some javascript to do that, unless you use a form > (you can always style the button to look like what you want). > > Fred >> >> >> 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! =* >> -- >> Posted via http://www.ruby-forum.com/. >> >>> > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Just also of interest, is this:> def lista_faculdade > teste = params[:teste] > @faculdade_teste = Curso.find(:all).select do |student| > student.faculdade_id = teste > endYou 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/ On 04/04/2008, at 4:35 AM, Laura Laizer smith wrote:> > Hi, I want to know how I can pass the following parameters ... > I have > faculdade: id, name > curso : id, faculdade_id > > and the following code > > #view > > <%= select(:curso, :faculdade_id , Faculdade.find(:all).collect {|c| > [c.nome, c.id] }) %> </p> > > <th><a href="curso/lista_faculdade?teste="+:faculdade_id> Preço > do Curso</a> </th> > > controller > > 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! =* > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> > 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 ! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Laura Laizer smith wrote:>> >> 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 !I tried the following #view Search: <input type="text" id="faculdade_find" name="search" /> <div id="results"></div> <%= observe_field ''faculdade_find'', :frequency => 0.5, :update => ''results'', :url => { :controller => ''curso'', :action=> ''lista_faculdade'' }, :with => "''search_text='' + escape(value)"%> #controller 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 ? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 = testeI 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> 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 ? > > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> 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) > > FredHalf 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 ... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Laura Laizer smith wrote:> Frederick Cheung wrote:You are doing it inside a for condition .... Dunno you can replace it but when you use do it''s a iteration... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---