SELECT * FROM messages match(caption, message) against (''Rails'')) ORDER BY caption!=''Rails'', caption, message How it will looks like in Ruby? This doesn''t work: @word = "Rails" @results = Blogs.paginate(:all, :order => ["caption!=?, caption, message", @word], :conditions => [ "match(caption,message) against (?)", @word], :page => params[:page], :per_page => 10) Problem is in: order => ["caption!=?, caption, message", @word] -- 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 -~----------~----~----~----~------~----~------~--~---
Hmm, I''m not Mr SQL, so I''m not sure what exactly this ORDER thing is doing.> @word = "Rails" > @results = Blogs.paginate(:all, :order => ["caption!=?, caption, > message", @word], :conditions => [ "match(caption,message) against (?)", > @word], :page => params[:page], :per_page => 10) > > Problem is in: order => ["caption!=?, caption, message", @word]yep. the [...] syntax works only for the :conditions You can just do: @results = Blogs.paginate(:all, :order => "caption!=#{@word}, caption, message", :conditions => [ "match(caption,message) against (?)", @word], :page => params[:page], :per_page => 10) Though you should make sure, nobody can inject any SQL in @word --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thorsten Mueller wrote:> @results = Blogs.paginate(:all, :order => "caption!=#{@word}, caption,What about security? Is it safe? -- 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 -~----------~----~----~----~------~----~------~--~---