I''m trying to develop a full-text search filtered by location and categories! My ugly way is to write different sql query''s for different solution, but i realize that is just stupid and ugly and didn''t do the job! Nifty_scaffold don''t work for me, i need the custom job! Are concatenating the parts of sql is hard in ruby? Can someone pass the link of tutorial or solution to this problem of mine? 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 -~----------~----~----~----~------~----~------~--~---
Are you talking about doing Unions in SQL? Or do you have multiple distinct results from different tables that you want to aggregate? On Sep 2, 10:23 am, UE RP <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''m trying to develop a full-text search filtered by location and > categories! > My ugly way is to write different sql query''s for different solution, > but i realize that is just stupid and ugly and didn''t do the job! > Nifty_scaffold don''t work for me, i need the custom job! > Are concatenating the parts of sql is hard in ruby? > Can someone pass the link of tutorial or solution to this problem of > mine? > Thanks in advance! > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jorg Lueke wrote:> Are you talking about doing Unions in SQL? > Or do you have multiple distinct results from different tables that > you want to aggregate?Jorg I''m talking about setting up a parts of sql like var1 = SELECT jobs.id, jobs.location, jobs.title, jobs.company, jobs.description, jobs.url FROM jobs var2 = WHERE jobs.id > 0 AND jobs.id = jobs_categories.job_id ................................. var3 = ta na na na GROUP BY categories.id ORDER BY categories.name ASC ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` and if defined?(some_value) then query = var1+vart3 else !defined?(some_value) then query = var1+vart2+var4 else !defined?(some_value) then query = var1+vart3+var4 end something like that! Or if u have a bather solution I''m listening! :) Thanks! -- 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 -~----------~----~----~----~------~----~------~--~---
Oh I see. That''s what I do. I actually have a model (not an active record base) that just generates SQL and it does exactly what you have. Input depends on the specific function, the pieces are added with ruby and the final sql in returned. Then I just access the methods from whatever controller needs them. It keeps all the sql generation in one place. On Sep 2, 10:40 am, UE RP <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Jorg Lueke wrote: > > Are you talking about doing Unions in SQL? > > Or do you have multiple distinct results from different tables that > > you want to aggregate? > > Jorg > I''m talking about setting up a parts of sql like > var1 = SELECT > jobs.id, > jobs.location, > jobs.title, > jobs.company, > jobs.description, > jobs.url > FROM > jobs > var2 = WHERE > jobs.id > 0 > AND jobs.id = jobs_categories.job_id > ................................. > var3 = ta na na na GROUP BY categories.id > ORDER BY categories.name ASC > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` > and if defined?(some_value) then > query = var1+vart3 > else > !defined?(some_value) then > query = var1+vart2+var4 > else > !defined?(some_value) then > query = var1+vart3+var4 > end > something like that! > Or if u have a bather solution I''m listening! :) > Thanks! > > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jorg Lueke wrote:> Oh I see. That''s what I do. I actually have a model (not an active > record base) that just generates SQL and it does exactly what you > have. Input depends on the specific function, the pieces are added > with ruby and the final sql in returned. Then I just access the > methods from whatever controller needs them. It keeps all the sql > generation in one place.Sounds cool and clean. Can you tell me hay u do it please. thanks! -- 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 -~----------~----~----~----~------~----~------~--~---