How to add a class to an input wrapper with simple_form

Depending on your simple_form settings it will most likely generate wrapper for all of your inputs. For example, if you’re using Bootstrap, then simple_form will add a div around your inputs that have a class of form-group. Sometimes you need to add a class to this wrapper and not directly to the input element. You can do that by using the wrapper_html argument when creating your simple_form input. Continue reading “How to add a class to an input wrapper with simple_form”

Using Templates from Custom Locations in Ruby on Rails

Most Rails developers are used to loading ERB or Haml templates from the filesystem. You throw your templates into app/views/* and everything works great. There are some situations where you might want to load your templates from other locations. You can load templates from wherever you want as long as you implement the correct API that Rails requires. Continue reading “Using Templates from Custom Locations in Ruby on Rails”

Ruby on Rails Common Commands & Code

Creating a project

Create a project and skip turbo links or spring

Start the server

Start and stop a server with passenger and some common arguments

Install your gems

Install gems specific to production

Compile front-end assets for production

Common database comments

Use scaffolding to create a resource

Generate a stand-alone controller

Generate a controller inside of a namespace

Create a stand-alone migration

Create a controller action

Create a model along with the migration

Create a link to resources

Models

Model manipulation

RSpec testing

RSpec with Capybara

RSpec for controllers

Run RSpec tests

Create RSpec helpers & matchers

Using FactoryGirl

Remove a column in a migration

Flash messaging

Redirecting

Allowing access to the request params with strong params

Displaying flash messages in the view

Define a piece of view code for an outer template in an inner template

Create a block in helpers for simpler if/else branching

Launch the rails console

Forms with simple_form

Getting the current page in a view

Routing

Access the nested namespace

View helpers

Views

Pundit

Testing Pundit

Responding with JSON

Testing an API

Returning status codes in the API