Created
July 30, 2013 13:42
-
-
Save TiuTalk/6113017 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# admin/posts/_form.html.haml | |
= f.actions do | |
= f.action :submit, button_html: { onclick: 'this.form.target = "_self"; return true' } | |
= f.action :submit, label: 'Preview', button_html: { onclick: 'this.form.target = "_blank"; return true' } |
This file contains hidden or 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
# admin/posts.rb | |
# encoding: utf-8 | |
ActiveAdmin.register Post do | |
controller do | |
def create | |
create! do |format| | |
format.html { redirect_to preview_or_back } | |
end | |
end | |
def update | |
update! do |format| | |
format.html { redirect_to preview_or_back } | |
end | |
end | |
private | |
def preview_or_back | |
if params[:commit] == 'Preview' | |
post_path(@post) | |
else | |
:back | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment