Created
June 5, 2012 09:04
-
-
Save geirarne/2873747 to your computer and use it in GitHub Desktop.
Slår meg som noe som burde kunne gjøres på 5 linjer. Men jeg får det ikke til.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Sculpture < ActiveRecord::Base | |
# some stuff here | |
def url | |
if I18n.locale == I18n.default_locale | |
'/'+slug | |
else | |
'/'+I18n.locale.to_s+'/'+slug | |
end | |
end | |
module Scopes | |
def published | |
where("is_published = ? AND published_at < ?", true, Time.now).order('lat DESC') | |
end | |
def published_map_markers | |
m = published.select("lat, lng, city, slug") | |
array = [] | |
m.each do |marker| | |
hash = { :lat => marker.lat, :lng => marker.lng, :city => marker.city, :slug => marker.slug, :url => marker.url } | |
array.push(hash) | |
end | |
array | |
end | |
end | |
extend Scopes | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problemet er altså
published_map_markers
, hvor jeg kun skal ha ut fire columns, pluss resultatet fra metodenurl