Skip to content

Instantly share code, notes, and snippets.

@nvandoorn
Created May 28, 2021 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nvandoorn/48315fce2fccf120da808b0d9f10ca47 to your computer and use it in GitHub Desktop.
Save nvandoorn/48315fce2fccf120da808b0d9f10ca47 to your computer and use it in GitHub Desktop.
# songs_controller.rb
class SongsController < ApplicationController
def index
@songs = Song.all
end
def show
@song = Song.find(param[:id])
end
def create
Song.create(params[:song])
end
end
# application_controller.rb
class ApplicationController < ActionController::Base
end
# routes.rb
Rails.application.routes.draw do
resources :songs, only: [:index, :show, :create]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment