-
Notifications
You must be signed in to change notification settings - Fork 0
rails Notes
- General Notes
- Benchmarking
- Rails Notes
- Useful Commands
- rails / Working with Databases
- rails 5 / General Notes
- General Useful Links
- rails follows the convention over configuration software design paradigm.
- rails v4.0 requires ruby >= 1.9.2
A pictorial πΈ diagram explaining rails
- model name is singular, ie.
mr_fancy_pant.rb
- database table name is plural, ie.
mr_fancy_pants
- migration files should follow the plural naming convention, ie.
20140528053443_create_mr_fancy_pants.rb
Benchmarking RVM Ruby 2.3.1, rails 4.2.x, execjs & rubyracer
Benchmarking RVM Ruby 2.5.3, rails 4.2.10, Node.js
- rails defaults to the system encoding which is UTF-8 the majority of the time.
- Generally it's a good idea to check and make sure databases have been created before trying to deploy a rails app.
to put a multiline comment in a .html.erb
file
<% if false %>
multiline
comment
in an erb template file
<% end %>
<%-# single line erb comment -%>
Rails version 5 has migrated from using
rake
torails
To install rails with no documentation
gem install rails --no-ri --no-rdoc
Three types of database relationship asociations
- one-to-one
- one-to-many
- many-to-many
To test the database connection
bundle exec rake db:schema:dump
To undo all migrations applied to a database
β οΈ All data in the database will be dropped, ie. deleted
bundle exec rake db:migrate VERSION=0
To get a list of all the migrations and their status
bundle exec rake db:migrate:status
To reset the database to its starting point
bundle exec rake db:migrate:reset
To create / setup databases for a rails version 4 app
rake db:create:all
To run all the migrations for the DB
rake db:migrate
To show the status of the migrations, ie. whether they have been applied or not
rake db:migrate:status
To remove a migration file
rails destroy migration 20140528053443_create_mr_fancy_pants.rb
To rollback one migration
rake db:rollback
To clear the contents of the DB
rake db:reset
To create a rails project without a test suite
rails new [project_name] -T
To delete a model
rails destroy model [model_name]
rails 5 requires Ruby >= 2.2.2 the
rails
command replacesrake
in rails 5
- The development server switched from WEBrick to Puma
- ActionCable is a framework for working with WebSockets
To create a new rails app that acts as a JSON API
rails new mr_fancy_pants_api --api
To remove border radius from a navbar, see
π¬blog post > rolling your own file attachment
- codeschool > Token Based Authentication in Rails
- building awesome rails API
- Building a RESTful API in a Rails Application
- railscasts > Securing an API
To show a an IRC users activity in the #rubyonrails channel on freenode
http://logs.ryanbigg.com/p/$USER/activity