views:

14

answers:

1

By @user.posts, I can see there is a post with :unfinished status.

But @user.posts.where('status = ?', :unfinished).all returns an empty array.

I've tried to invoke @user.reload first, but it doesn't resolve the problem.

(rdb:568) @user.posts
[#<Post id: 1, content: "hehe", user_id: 1, created_at: "2010-04-03 06:16:47", updated_at: "2010-04-03 06:16:47", status: "--- :unfinished\n">]

(rdb:568) @user.posts.where('status = ?', :unfinished).all
[]

update:

Oh, I see. Rails doesn't escape :unfinished well, it missing the closing '

status = '--- :unfinished\n

+1  A: 

@user.posts.where('status = :status',{:status => 'unfinished'}).all

Eimantas