validate: true not forcing conditional validation on f.text_field #443

ccmcbeck opened this Issue Nov 29, 2012 · 3 comments


None yet

2 participants


First, of all, this gem with the new simple-form plugin is awesome. I may have a rails or ruby issue, but if I follow the wiki docs to force a conditional validation such as

validates :first_name, presence: true, if: true

by entering

<%= f.text_field :first_name, validate: true %>

I get an error message from the template

true is not a symbol

Perhaps it's a Gemfile issue. I'm using rails 3.2.6


@ccmcbeck if passing :if => true is a valid option then this is a bug but I'm curious to know why that would be a conditional in the first place? It seems unnecessary.

@bcardarella bcardarella added a commit that closed this issue Nov 29, 2012
@bcardarella bcardarella Ensure conditional values are not methods
Will eval the value if not a method on the object

Closes #443

@ccmcbeck if you point your Gemfile to the 3-2-stable branch give that a try

@bcardarella thanks for the rapid responses. This is my bust.

if: true was my attempt to simplify the example. However, conditional validations are only supposed to take Symbol, String (that gets eval'd) or Proc. Therefore, true is not a symbol was a red herring.

The real problem was my controller which only enabled the validation on POST operations. For client-side-validations, they must be enabled on GET as well.

My apologies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment