Created
November 4, 2008 23:46
-
-
Save lukesutton/22262 to your computer and use it in GitHub Desktop.
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
# Called like: | |
@page = Page.first_with_localization(:path =>"about_us", :dialect_id => 2, :locale_id => 1) | |
def self.first_with_localization(options) | |
if options[:path] == "" or options[:path].nil? | |
options.delete(:path) | |
page = Page.first(:home => true) | |
raise DataMapper::ObjectNotFoundError unless page | |
localization = page.localizations.first(options) | |
raise DataMapper::ObjectNotFoundError unless localization | |
else | |
localization = PageLocalization.first(options) | |
raise DataMapper::ObjectNotFoundError unless localization | |
page = localization.page | |
end | |
page.current_localization = localization | |
page | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment