Skip to content

Instantly share code, notes, and snippets.

@aspencer8111
Created May 30, 2017 21:57
Show Gist options
  • Save aspencer8111/c5ad06da7975cb40e6f7f84754ca001a to your computer and use it in GitHub Desktop.
Save aspencer8111/c5ad06da7975cb40e6f7f84754ca001a to your computer and use it in GitHub Desktop.
Routes n stuff
resources :widgets
# Create
GET /widgets/new -> New action controller -> @widget = Widget.new -> view
POST /widgets -> Create action controller -> @widget.save(params) -> reidrect
# Read
GET /widgets -> Index action controller -> @widgets = Widget.all
GET /widgets/:id -> Show action controller -> @widget = Widget.find(params(:id))
# Update
GET /widgets/:id/edit -> Edit action controller -> @widget = Widget.find(:id) -> view
PUT /widgets/:id -> Update action controller -> @widget.save(new params) -> reidrect
# Delete
Destroy /widgets/:id -> Destroy action controller -> @widget.find(params[:id]).destroy -> redirect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment