Last active
December 18, 2015 07:09
-
-
Save justinleveck/5744501 to your computer and use it in GitHub Desktop.
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
#models / concerns / create_shout.rb | |
module Concerns | |
module CreateShout | |
extend ActiveSupport::Concern | |
def create | |
content = build_content | |
shout = current_user.shouts.build(content: content) | |
shout.save | |
if shout.save | |
redirect_to dashboard_path | |
else | |
flash.alert = "Could not shout" | |
redirect_to dashboard_path | |
end | |
end | |
end | |
end |
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
class PhotoShoutsController < ApplicationController | |
include Concerns::CreateShout | |
private | |
def build_content | |
PhotoShout.new(photo_shout_parameters) | |
end | |
def photo_shout_parameters | |
params.require(:photo_shout).permit(:image) | |
end | |
end |
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
class TextShoutsController < ApplicationController | |
include Concerns::CreateShout | |
private | |
def build_content | |
TextShout.new(text_shout_parameters) | |
end | |
def text_shout_parameters | |
params.require(:text_shout).permit(:body) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment