这是indexloc提供的服务,不要输入任何密码
Skip to content
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] %>