3

So I have a field in the question table, called is_public..I migrated my database, restarted it and now when I get this error everytime I call is_public for a record in the question records.

undefined method `is_public' for #<Question:0x7e9aa780>

Any ideas to why this is happening ?

9
  • That's a strange bug. Did the migrations successfully migrate? can you reproduce the error in console? Is your model inheriting from ActiveRecord? Commented Feb 17, 2011 at 18:34
  • Is is_public listed when you call question.attributes.keys ? Is is_public a boolean field? If so, then use ? at end: is_public?. Ps. This is not an answer, cos I dunno if you will accept it :D Commented Feb 17, 2011 at 18:42
  • 1
    What happens when you call is_public? (with the question mark)? Commented Feb 17, 2011 at 19:41
  • 1
    Please show us your db/schema.rb code for the questions table. Commented Feb 17, 2011 at 20:28
  • 1
    If you're problem appears when using views, you might want to show your view(s) and controller code. Commented Feb 17, 2011 at 20:31

2 Answers 2

1

Not sure if this was the issue, but I had the same problem, and it looks like somehow my schema.rb file was changed, removing that column.

I manually added it back, and the error went away.

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

Comments

0

Are you using attr_accessible? If so, add :is_public to the list.

1 Comment

I'm running into a similar issue; I tried your suggestion and I'm still getting the no method error. Migration was successful in that the fields are in the table. Any other suggestions? ( it seems silly to open a new question for what sounds like the exact same issue... )

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.