# Checkboxes returning true or false

**URL:** <https://www.ruby-forum.com/t/checkboxes-returning-true-or-false/90637>\
**Category:** Rails\
**Created:** [March 30, 2007, 4:28pm UTC](https://www.ruby-forum.com/t/checkboxes-returning-true-or-false/90637 "2007-03-30T16:28:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jordelver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@jordelver](https://www.ruby-forum.com/u/jordelver)\
**Post date:** [March 30, 2007, 4:28pm UTC](https://www.ruby-forum.com/t/checkboxes-returning-true-or-false/90637/1 "2007-03-30T16:28:43Z")

</div>

Hi,  
I’ve got a checkbox on my form that the user checks to say whether  
they want to receive a newsletter or not. It looks like this:

 \<%= check\_box :customer, :subscribe\_to\_newsletter %\> \<%= submit\_tag "Create Customer" %\> 

The subscribe\_to\_newsletter attribute is not in the database, just a  
attr\_accessor :subscribe\_to\_newsletter.

I need to write a method to show whether this has been checked or not.  
I believe that if the attribute was in the database, then a question  
mark method such as subscribe\_to\_newsletter? would automatically  
written for me to return true or false. But, it’s not in the database.

I’ve written this so far, which works, but is there a better way which  
I am missing?

def receive\_newsletter?  
subscribe\_to\_newsletter == “1” ? true : false  
end

Thanks,  
Jord
