Skip to content

Instantly share code, notes, and snippets.

@DriesS

DriesS/item.rb Secret

Created December 3, 2014 15:47
Show Gist options
  • Save DriesS/be96a361727931c771d7 to your computer and use it in GitHub Desktop.
Save DriesS/be96a361727931c771d7 to your computer and use it in GitHub Desktop.
How to overwrite method
require 'acts_as_indexed'
module Refinery
module News
class Item < Refinery::Core::BaseModel
class << self
# rejects any page that has not been translated to the current locale.
def translated
includes(:translations).where(
translation_class.arel_table[:locale].eq(::Globalize.locale)
).where(
arel_table[:id].eq(translation_class.arel_table[:refinery_news_item_id])
)
end
end
end
end
end
Refinery::News::Item.class_eval do
def translated
puts "overwritten"
# includes(:translations).where(
# translation_class.arel_table[:locale].eq(::Globalize.locale)
# ).where(
# arel_table[:id].eq(translation_class.arel_table[:refinery_news_item_id])
# )
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment