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 error when clicking on 'save & continue' then changing locale #487

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
40 changes: 40 additions & 0 deletions app/controllers/refinery/blog/admin/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,38 @@ def create
end
end

def update
if @post.update_attributes(post_params)
flash.notice = t('refinery.crudify.updated', what: "'#{@post.title}'")

if from_dialog?
self.index
@dialog_successful = true
render :index
else
if params[:continue_editing] =~ /true|on|1/
if request.xhr?
render partial: 'save_and_continue_callback',
locals: save_and_continue_locals(@post)
else
redirect_to :back
end
else
redirect_back_or_default(refinery.blog_admin_posts_path())
end
end
else
if request.xhr?
render :partial => '/refinery/admin/error_messages', :locals => {
:object => @post,
:include_object_name => true
}
else
render 'edit'
end
end
end

def delete_translation
find_post
@post.translations.find_by_locale(params[:locale_to_delete]).destroy
Expand All @@ -95,6 +127,14 @@ def permitted_post_params
]
end

def save_and_continue_locals(post)
{
new_refinery_edit_post_path: refinery.edit_blog_admin_post_path(post),
new_refinery_post_path: refinery.blog_admin_post_path(post),
new_post_path: refinery.blog_post_path(post)
}
end

protected

def find_post
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= render '/refinery/message' %>
<%= hidden_field_tag 'new_action', local_assigns[:new_refinery_post_path] %>
<%= hidden_field_tag 'new_refinery_edit_page_path', local_assigns[:new_refinery_edit_post_path] %>