Created
October 17, 2017 20:52
-
-
Save negabaro/b02bbcd23e444715f6cf7e800561a92a to your computer and use it in GitHub Desktop.
Rails AASM controller example
This file contains 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
def create | |
@article = current_user.articles.build(article_params) | |
if @article.valid? | |
@article.save! | |
case params[:ope][:cmd] | |
when 'publish' | |
@article.publish! | |
puts "hi this is publish zone" | |
flash[:success] = '記事を公開しました。' | |
when 'save' | |
#@article.draft! | |
puts "hi this is draft zone" | |
flash[:success] = '記事を保存しました。' | |
else | |
raise | |
end | |
redirect_to @article | |
else | |
redirect_to :new | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment