Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix updating attachments in Rails 6 #946

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/comfy/cms/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def assign_label

def process_attachment
return if @file.blank?
attachment.attach(@file)
self.attachment = @file
end

end
23 changes: 18 additions & 5 deletions app/models/comfy/cms/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/comfortable_mexican_sofa/routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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