Ruby on Rails
Tuesday, June 10, 2014
I now have:
model:
attr_accessor :completed_cfdym
def completed_cfdym
@completed_cfdym
end
def completed_cfdym=(var)
if var == 'true'
@completed_cfdym = true
else
if var == 'false'
@completed_cfdym = false
else
@completed_cfdym = ''
end
end
end
validates(:completed_cfdym, inclusion: { in: [true, false], message: "%{value} is not a valid response"} )
view:
<%= f.label :completed_cfdym, "Have you already completed 'A Conversation for the Difference You Make in Life?", class: 'span5' %>
<%= f.select :completed_cfdym, {'' => nil, 'Yes' => true, 'No' => false}, {}, { :class => 'span1' } %>
I get the diagnostic:
* Completed cfdym is not a valid response
Is there a construct, like the %{value} that I can use to print out the response?
On Tuesday, June 10, 2014 3:12:33 AM UTC-7, Frederick Cheung wrote:
-- model:
attr_accessor :completed_cfdym
def completed_cfdym
@completed_cfdym
end
def completed_cfdym=(var)
if var == 'true'
@completed_cfdym = true
else
if var == 'false'
@completed_cfdym = false
else
@completed_cfdym = ''
end
end
end
validates(:completed_cfdym, inclusion: { in: [true, false], message: "%{value} is not a valid response"} )
view:
<%= f.label :completed_cfdym, "Have you already completed 'A Conversation for the Difference You Make in Life?", class: 'span5' %>
<%= f.select :completed_cfdym, {'' => nil, 'Yes' => true, 'No' => false}, {}, { :class => 'span1' } %>
I get the diagnostic:
* Completed cfdym is not a valid response
Is there a construct, like the %{value} that I can use to print out the response?
On Tuesday, June 10, 2014 3:12:33 AM UTC-7, Frederick Cheung wrote:
On Monday, June 9, 2014 8:34:19 PM UTC+1, Asa Romberger wrote:Removing the '' on true and false made no difference.You're comparing with = rather than ==Fred
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/205223dc-31cd-4816-a501-569fa852f67a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment