diff --git a/app/models/comfy/cms/file.rb b/app/models/comfy/cms/file.rb index 19b05ce45..69ffbf5bc 100644 --- a/app/models/comfy/cms/file.rb +++ b/app/models/comfy/cms/file.rb @@ -56,7 +56,7 @@ def assign_label def process_attachment return if @file.blank? - attachment.attach(@file) + self.attachment = @file end end diff --git a/app/models/comfy/cms/page.rb b/app/models/comfy/cms/page.rb index 46d7ca061..e18a1fea6 100644 --- a/app/models/comfy/cms/page.rb +++ b/app/models/comfy/cms/page.rb @@ -85,12 +85,8 @@ def url(relative: false) # This method will mutate page object by transfering attributes from translation # for a given locale. - def translate! - # If site locale same as page's or there's no translastions, we do nothing - if site.locale == I18n.locale.to_s || translations.blank? - return - end + def translation translation = translations.published.find_by!(locale: I18n.locale) self.layout = translation.layout self.label = translation.label @@ -104,6 +100,23 @@ def translate! self end + + def translate! + if site.locale == I18n.locale.to_s + return + end + + translation + end + + def translate + # If site locale same as page's or there's no translastions, we do nothing + if site.locale == I18n.locale.to_s || translations.blank? + return + end + + translation + end protected diff --git a/lib/comfortable_mexican_sofa/routing.rb b/lib/comfortable_mexican_sofa/routing.rb index 56cd62466..2f700693a 100644 --- a/lib/comfortable_mexican_sofa/routing.rb +++ b/lib/comfortable_mexican_sofa/routing.rb @@ -6,7 +6,7 @@ class ActionDispatch::Routing::Mapper def comfy_route(identifier, options = {}) - send("comfy_route_#{identifier}", options) + send("comfy_route_#{identifier}", **options) end end