Home

Rails Useful Tidbits

tl;dr

Rails Console

CommandAction
app.get "/route"Test a get route
Model.allGet array of model
Modal.firstGet first of model
Model.find(:id)Find model by ID

Decent Exposure

A popular Rails gem helper for creating declarative interfaces in controllers. Link here.

class ThingsController < ApplicationController # all the follpowing do the same way expose :thing, fetch: ->{ get_thing_some_way_or_another } expose(:thing){ get_thing_some_way_or_another } expose :thing, ->{ get_thing_some_way_or_another } expose :thing, :get_thing_some_way_or_another end

Repository

https://github.com/okeeffed/developer-notes-nextjs/content/ruby/rails-useful-tidbits

Sections


Related