Skip to content

Instantly share code, notes, and snippets.

@RachelSa
Created August 13, 2017 15:47
Show Gist options
  • Save RachelSa/910d868ca7180fcbb94e1367be0912da to your computer and use it in GitHub Desktop.
Save RachelSa/910d868ca7180fcbb94e1367be0912da to your computer and use it in GitHub Desktop.
class ClassroomsController < ApplicationController
def update
@classroom = Classroom.find(params[:id])
if @classroom.update(classroom_params)
redirect_to users_path, :notice => "#{@classroom.name} updated"
else
flash[:notice] = "Classrooms must have a name"
@programs = Program.all
render :edit
end
end
private
def classroom_params
params.require(:classroom).permit(:name, :location, :map_url, :image_url, :description, :longitude, :latitude, :google_address, :phone, {:program_ids => []})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment