Sha256: c7290886d349fe5d92fb8e34d4c1f6dae7d6f0c9dcb58a77211a06aef58f9a5a

Contents?: true

Size: 885 Bytes

Versions: 3

Compression:

Stored size: 885 Bytes

Contents

require_dependency "feedback_gem/application_controller"

module FeedbackGem
  class FeedbacksController < ApplicationController
  	def index
  		@feedbacks = Feedback.all
  	end
  	def new
  		@feedback = Feedback.new
  	end
  	def show
  		feedback
  	end
  	def create
  		@feedback = Feedback.new(feedback_params)
  		if@feedback.save
  			redirect_to @feedback
  		else
  			render 'new'
  		end
  	end
  	def edit
  		feedback
  	end
  	def update
  		# binding.pry
  		feedback
  		if @feedback.update(feedback_params)
  			redirect_to feedbacks_path
  		else
  			render 'edit'
  		end
  	end
  	def destroy
  		feedback
  		@feedback.destroy
  		redirect_to feedbacks_path
  	end
  	private
  	def feedback_params
  		params.require(:feedback).permit(:name,:email,:subject,:description)
  	end
  	def feedback
  		@feedback = Feedback.find_by(id:params[:id])
  	end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
feedback_gem-0.2.0 app/controllers/feedback_gem/feedbacks_controller.rb
feedback_gem-0.1.2 app/controllers/feedback_gem/feedbacks_controller.rb
feedback_gem-0.1.1 app/controllers/feedback_gem/feedbacks_controller.rb