# :order =\>

**URL:** <https://www.ruby-forum.com/t/order/146779>\
**Category:** Rails\
**Created:** [August 25, 2008, 12:30pm UTC](https://www.ruby-forum.com/t/order/146779 "2008-08-25T12:30:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [August 25, 2008, 12:30pm UTC](https://www.ruby-forum.com/t/order/146779/1 "2008-08-25T12:30:46Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [August 25, 2008, 12:41pm UTC](https://www.ruby-forum.com/t/order/146779/2 "2008-08-25T12:41:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [August 27, 2008, 1:48pm UTC](https://www.ruby-forum.com/t/order/146779/3 "2008-08-27T13:48:20Z")

</div>

Thorsten M. wrote:

> @results = Blogs.paginate(:all, :order =\> "caption!=#{@word}, caption,

What about security? Is it safe?
