Skip to content

Instantly share code, notes, and snippets.

@miker-mcd
miker-mcd / routes.rb
Created September 21, 2017 17:02 — forked from marksiemers/routes.rb
Example of nesting routes in rails
Rails.application.routes.draw do
concern :reviewable do
resources :reviews, only: [:new, :create, :index]
end
resources :reviews, only: [:show, :delete, :edit, :update]
resources :artists, :albums, :songs, :lyrics, only: [], concerns: :reviewable
resources :artists do
@miker-mcd
miker-mcd / OOJS
Created September 12, 2017 22:40 — forked from markjnkim/OOJS
OOJS prototypes
################################################################
##################### OOJS Stamps ##################
################################################################
var StampCollection = function(stamps){
this.stamps = stamps
}
StampCollection.prototype.stampNamed = function (stampName) {
return this.stamps.find(function(stamp){
@miker-mcd
miker-mcd / index.md
Created September 12, 2017 22:39 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@miker-mcd
miker-mcd / Login boiler plate CRUD
Created September 12, 2017 22:38 — forked from markjnkim/Login boiler plate CRUD
Login in boiler plate CRUD Bcrypt
############################################################################
####################### SERVER SIDE CONTROLLER #######################
############################## Routes #################################
############################################################################
post '/potlucks/:id/attendances' do
@attendance = Attendance.new(attendee_id: current_user.id, potluck_id: params[:id],dish: params[:dish])
if @attendance.save
redirect "/potlucks/#{params[:id]}"
else
@error_messages = @attendance.errors.full_messages