1

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 to 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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Hm, that does change the record in my database, but I am still unable to find that record when using .where(:is_approved => false) or true...
No wait! I take that back. It seems to be working now. I think I had to update it as true and then update it as false again. I guess active record saw that it already was "true" so it ignored the update until I changed it back to false. Thanks man.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.