georgebellos/real_estate

View on GitHub
app/helpers/properties_helper.rb

Summary

Maintainability
A
0 mins
Test Coverage
module PropertiesHelper
  def thumbnail(property, size)
    image = property.images.first
    image ? image.attachment.url(size) : Image.new.attachment.url
  end

  def property_search_results(properties)
    if properties.total_count > 0
      content_tag(:div, "Found #{ properties.total_count } property listings with this search criteria'",
                  class: 'alert alert-info alert-block')
    else
      content_tag(:div, "No property listings were found with this search criteria",
                  class: 'alert alert-block')
    end
  end

  def summary(property)
    if controller.action_name == "buy" || controller.action_name == "rent"
      property.category
    else
      property.title
    end
  end
end