Sha256: d46c3e05c0df8ec15b59033ee904aabe2a0de39e0f7aed87a310a8e8f30a7ea6

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

class SchedulesController < ApplicationController

	def index
		@schedules = Schedule.all
	end

	def filter_schedules
		@start_date, @end_date = params[:start_date], params[:end_date]
		@schedules = Schedule.where(birthday: @start_date..@end_date)
	end

	def new
		@schedule = Schedule.new
	end


	def edit
		@schedule = Schedule.find(params[:id])
	end

	def edit_in_modal
		@schedule = Schedule.find(params[:id])
		render :edit, layout: false
	end

	def edit_with_index
		@schedule = Schedule.find(params[:id])
		@schedules = Schedule.all
	end

	def create
		@schedule = Schedule.new(schedule_params)
		if @schedule.save
			redirect_to edit_schedule_url(@schedule)
		else
			flash[:alert] = "Unable to save schedule"
			render :new
		end
	end

	def update
		@schedule = Schedule.find(params[:id])
		if @schedule.update_attributes(schedule_params)
			redirect_to edit_schedule_url(@schedule)
		else
			flash[:alert] = "Unable to save schedule"
			render :edit
		end
	end


	def new_custom
		@schedule = Schedule.new
	end

	def edit_custom
		@schedule = Schedule.find(params[:id])
	end


	private
	def schedule_params
		params.require(:schedule).permit(:name, :lunchtime, :apocalypse, 
										:birthday, :alarm_setting, :epoch, :christmas, :suppertime, :beer_oclock,
										:sleepytime, :party_time, :easter, :date_in_time)
	end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hot_date_rails-1.5.7 spec/dummy/app/controllers/schedules_controller.rb