Reputation: 7230
I can't get the following syntax to work:
if document.anonymous == false ?
I get this error: " syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '(' "
Here is the corresponding field for "anonymous" in the document model
field :anonymous, type: Boolean, default: true
Thank you in advance!
Upvotes: 1
Views: 8133
Reputation: 464
Anyone looking at this now, for booleans you can simply use:
document.anonymous?
- returns true
for boolean with value 1
!document.anonymous?
- returns true
for boolean with value 0
Upvotes: 0
Reputation: 47532
either use
if document.anonymous == false #OR unless document.anonymous
else
end
OR
document.anonymous == false ? () : ()
Note:- In Ruby only false and nil are falsey. Ref this
Upvotes: 1
Reputation: 24815
There should not be question mark. Use this
if document.anonymous == false
Upvotes: 1
Reputation: 5734
Try unless document.anonymous
in stead of if document.anonymous == false ?
Upvotes: 3