class Public::QuotesController < ApplicationController
  layout "public"
  

  def index
    
    @quotes = Quote.where(:enabled => true).all
  end


  def show
    @quote = Quote.find(params[:id])

  end


  def new
    @quote = Quote.new
  
  end
  
  def newphoto
    @quote = Quote.new(:photo_id => params[:photo_id])
    @photo = Photo.find(params[:photo_id])
  
  end
  
  def createphoto
  	@quote = Quote.new(quote_params)
    @quote.public_from = true
    if @quote.save
      @quotes = Quote.all
      @photo = @quote.photo
          
  	else
  		render :action => "newphoto" 
  	end
  end
  


  def create
  	@quote = Quote.new(quote_params)
    @quote.public_from = true
    if @quote.save
      @quotes = Quote.all
          
  	else
  		render :action => "new" 
  	end
  end

  		

  
  private
      def quote_params
        params.require(:quote).permit(:quote, :author, :photo_id)
      end



end
