Module: Carload::ApplicationHelper

Defined in:
app/helpers/carload/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#image?(attribute_name) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'app/helpers/carload/application_helper.rb', line 11

def image? attribute_name
  attribute_name.to_s =~ /image|logo|img/
end

#needs_upload?(model_name, attribute_name) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
# File 'app/helpers/carload/application_helper.rb', line 3

def needs_upload? model_name, attribute_name
  case Carload.upload_solution
  when :carrierwave
    model_class = model_name.to_s.classify.constantize
    not model_class.instance_methods.map(&:to_s).select { |x| x =~ /#{attribute_name}_url/ }.empty?
  end
end