RailsCasts Pro episodes are now free!

Learn more or hide this

Stephanie H. Chang's Profile

GitHub User: stchangg

Site: www.stchangg.com

Comments by Stephanie H. Chang

Avatar

Is there any significant performance penalty for calling object.class.validators_on(name).any? (below) for every field? Would it be measurably better to move this array retrieval to the form level?

ruby
  def field_label(name, *args)
    options = args.extract_options!
    required = object.class.validators_on(name).any? { |v| v.kind_of? ActiveModel::Validations::PresenceValidator }
    label(name, options[:label], class: ("required" if required))
  end

Also, the snap before the delegate refactoring was awesome. Thanks Ryan!

Avatar

Just as UP4B LLC mentioned, rails g devise_views is deprecated. It's now rails g devise:views.

Source: (https://github.com/plataformatec/devise/issues/634)