开发者

Rails SQlite boolean problem

开发者 https://www.devze.com 2023-04-02 21:18 出处:网络
I am running Rails 3.0.9 and SQlite3 1.3.4 I have created a boolean called is_approved on my photos table.

I am running Rails 3.0.9 and SQlite3 1.3.4

I have created a boolean called is_approved on my photos table.

add_column("photos", "is_approved", :boolean, :default => false)

It stores these as 't' and 'f' in my database, but I have no problem with that.

I have a view which displays all records that have an is_approved value of "false".

def moderate 
  @photos = Photo.where(:is_approved => false)
end

This works fine too, even though the database stored 't's and 'f's.

I run into a problem when I manually (in my db viewing app or in rails console) change a record's is_approved value t开发者_开发知识库o true or false or t or f or 1 or 0. When I do that, the record is no longer recognized no matter how I call it.

Anyone have any thoughts? Can I clarify my issue more?


It probably is some sort of encoding issue. Use the rails console and do:

photo.update_attribute(:is_approved, false)

Then it will go through active record.

0

精彩评论

暂无评论...
验证码 换一张
取 消