Skip to content

Instantly share code, notes, and snippets.

<%= render file: 'view_directory/file_name'%>
var exclaim = (string) => {return string + "!"}
var words = ["let's", "do", "this"]
console.log(words.map(exclaim))
var exclaim = (string) => {return string + "!"}
var words = ["let's", "do", "this"]
console.log(words.map(exclaim))
//[ 'let\'s!', 'do!', 'this!' ]
$(".title").removeClass("light-blue")
@RachelSa
RachelSa / rails_collection_check_boxes.erb
Created August 12, 2017 23:11
Rails collection_check_boxes
<%= f.collection_check_boxes :program_ids, @programs, :id, :title %>
@RachelSa
RachelSa / rails_collection_check_boxes_with_iteration.erb
Created August 12, 2017 23:23
Rails collection checkboxes with iteration
<%= f.collection_check_boxes(:program_ids, @programs, :id, :title) do |b| %>
<div> <%= b.check_box %><%= b.label { b.text } %></div>
<% end %>
<% end %>
class ClassroomsController < ApplicationController
def update
@classroom = Classroom.find(params[:id])
if @classroom.update(classroom_params)
program_ids = classroom_program_params[:program_ids].delete_if {|program| program == ""}
@programs = program_ids.map {|id| Program.find(id)}
@classroom.update(programs: @programs)
redirect_to users_path, :notice => "#{@classroom.name} updated"
else
flash[:notice] = "Classrooms must have a name"
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
function eventLoop(){
setTimeout(() => {console.log(3)},0)
console.log(1)
return 2
}
eventLoop()
function concat(first, last){
return `${first} ${last}`
}
function greet(f, l){
console.log(`Hi, ${concat(f, l)}`)
}
greet("Gabi", "Granger")