Last active
September 13, 2019 22:48
-
-
Save eri-b/cb1cb16e5e9c6472f2810957de9ed705 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
| class SitesController < ApplicationController | |
| before_action :find_site, only: [:show] | |
| def show | |
| if @site.nil? | |
| @site = Site.new(name: @slug) | |
| if @site.save | |
| flash.now[:notice] = "Your site is ready. Hi #{@slug} :)" | |
| else | |
| redirect_to main_path("faq"), alert: "Site not saved. Letter, numbers, and dashes accepted." | |
| end | |
| end | |
| @feed = @site.posts.order("created_at DESC") | |
| end | |
| private | |
| def find_site | |
| @slug = params[:id].downcase | |
| @site = Site.find_by(name: @slug) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment