Meaning that, in PostsController, def create, I want to access the value that is passed in the column for the boolean value agree. When creating a post, there is a checkbox that sets this value. Checked makes agree true (1) and unchecked makes agree false (0). Right now I have the code params[:post][:agree] in order to access this value, but that doesn’t seem to work.
When I try to use that in an if statement, the statement always occurs, as if params[:post][:agree] always evaluates to true.
Help! Why doesn’t this work??
:EDIT:
Post.rb (Post Model)
attr_accessor :agree
attr_accessible :agree
PostController (In def create)
@post.title = "AGREED!!" if params[:post][:agree] == "1"
In Ruby, neither the number
0nor the string"0"evaluates tofalsein a boolean context. Tryif (params[:post][:agree]=="1")