Skip to content

Instantly share code, notes, and snippets.

@regularlady
Created April 20, 2016 23:22
Show Gist options
  • Save regularlady/ba3eb3244e55ac55cb8a86da85b8b142 to your computer and use it in GitHub Desktop.
Save regularlady/ba3eb3244e55ac55cb8a86da85b8b142 to your computer and use it in GitHub Desktop.
def create
@sponsored_post = SponsoredPost.new
@sponsored_post.title = params[:sponsored_post][:title]
@sponsored_post.body = params[:sponsored_post][:body]
@sponsored_post.price = params[:sponsored_post][:price]
topic = Topic.find(params[:topic_id])
@sponsored_post.topic = topic
if @sponsored_post.save
flash[:notice] = "Sponsored post was saved."
redirect_to [topic, @sponsored_post]
else
flash[:error] = "There was an error saving the sponsored post. Please try again."
render :new
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment