métodos rails helper para carregar imagens lorempixel.com

Simplesmente cole o snippet abaixo em seu application_helper.rb (ou qualquer outro arquivo _helper.rb) e você obterá imagens “lorem ipsum” para usar como marcadores em seus projetos. Usei o meu em uma página 404, por exemplo.

Em suas visualizações, use-o assim:

<%= image_tag people_url(width: 200, height: 200), class: 'thumbnail', alt: 'People' %>

Aviso de sintaxe Ruby 2.0 à frente;)

IMAGE_CATEGORIES = %w(abstract animals business cats city sports fashion nature food nightlife people technics transport)

# creates helper methods for each image category:
#
# abstract_url width: 200, height: 100
# animals_url width: 300, height: 400
# ...
#
IMAGE_CATEGORIES
.each do |category|
define_method
("#{category}_url") do |width:, height:|
"//lorempixel.com/#{width}/#{height}/#{category}/"
end
end