Skip to content

Instantly share code, notes, and snippets.

@heardk
Last active December 10, 2016 14:31
Show Gist options
  • Save heardk/7161acd09ec5dc9edd84 to your computer and use it in GitHub Desktop.
Save heardk/7161acd09ec5dc9edd84 to your computer and use it in GitHub Desktop.
Command List
RAILS
rails new ApplicationName – Create a new application
rails generate/g model ModelName – Creates a model with the specified model_name
rails generate/g controller ControllerName – Creates a controller with the specified controller_name
rails generate/g migration MigrationName – Creates a migration with the specified migration_name
rails generate migration AddPartNumberToProducts
rails generate/g scaffold ModelName ControllerName – A shortcut for creating your controller, model and view files etc
rails g scaffold Admin::FileShare location:string access_type:string - Prefix a namespace for a model
rails generate resource NAME - Stubs out a controller without any actions and no views, but does include routes and tests ..
rails destroy controller ControllerName – Destroys the created controller and its related file.
rails destroy scaffold MyScaffold - Destroy all Scaffold
rails server/s – start ruby server at http://localhost:3000
rails console -s - start the console within a transaction and rollsback all changes made
rake db:create – Create the database defined in config/database.yml for the current RAILS_ENV
rake db:drop – Drops the database for the current RAILS_ENV
rake db:migrate – Migrate the database through scripts in db/migrate folder.
rake db:reset – Drops and recreates the database from db/schema.rb for the current environment and runs db:seed as well.
rake db:rollback – This will run the down method from the latest migration.
rake db:schema:load - Load schema back to original based on current schema file
rake -T - Lists all rake tasks
rake -T db - Lists all rake db tasks
TESTS
rake test – Run all unit, functional and integration tests
rake test:functionals – Run tests for functionalsdb:test:prepare / Run the functional tests in test/functional
rake test:integration – Run tests for integrationdb:test:prepare / Run the integration tests in test/integration
rake test:units – Run tests for unitsdb:test:prepare / Run the unit tests in test/unit
rake tmp:clear – Clear session, cache, and socket files from tmp/
BOOTSTRAP
rails generate bootstrap:install less - Less Install
rails generate bootstrap:install static - Static Install
rails g bootstrap:layout application fixed - Example of a fixed layout
rails g bootstrap:layout application fluid - Example of a responsive layout
rails g scaffold Post title:string description:text --no-stylesheets
rake db:migrate
rails g bootstrap:themed Posts
GIT
git clean -f - Remove untracked and changed files and folders
git clean -f -d - Remove untracked and changed files and folders
git clean -f -X - Remove untracked and changed files only as well as ignored files
git add -u - Automatically stage tracked files -- including deleting the previously tracked files
git commit --amend -m "New commit message" - Amend to the last commit
git checkout -b 'refactored' -- create a new branch called refactored and checkout this new branch
RVM
rvm install 1.9.3 -- Install Ruby 1.9.3
rvm --default use 1.9.3 -- Set Ruby 1.9.3 as the default version
rvm system -- If you ever want to go back to the system-installed Ruby version
rvm 1.9.3 -- And to switch back to Ruby 1.9.3
rvm use 1.9.2-head@albinochipmunk --create -- Create a gemset specific to a ruby version and project
rvm gemset list -- Lists all gemsets
rvm gemset use gemsetname -- changes to the gemsetname used here
RUBY GEMS
gem build <file>.gemspec -- Build Gem
gem install <file>.gem -- Install Gem Locally
gem push <file>.gem -- Publish To RubyGems
gem search -r <gem name> -- Search
gem install <gem name> -- Install from RubyGems
gem yank <gem name> -v <version> -- Yank Gem
gem clean -- Cleans/removes any unneccessary gems
gem list -- lists all gems installed
gem update -- updates any out of date gems
gem outdated -- lists gems that are out of date
RSPEC
rspec -- runs tests
rspec -f d -- run tests with documentation and colour
rspec --colour -- runs tests with colour in the output
rake db:test:prepare -- setup db for tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment