Install RVM
https://rvm.io/rvm/install/
Update RVM
rvm get stable
Install Ruby dependencies
Install RVM
https://rvm.io/rvm/install/
Update RVM
rvm get stable
Install Ruby dependencies
Access MySQL server from the mysql client using a username and password (MySQL will prompt for a password):
mysql -u [username] -p;
Exit
exit;
If a public/assets/manifest.yml is detected in your app, Heroku will assume you are handling asset compilation yourself and will not attempt to compile your assets. To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated.
RAILS_ENV=production bundle exec rake assets:precompile
rails g scaffold Model field:type field:type | |
rails generate scaffold Model [field[:type][:index/uniq] field[:type][:index/uniq]] [otherModel:references] [options] | |
references or belongs_to | |
type: binary, boolean, date, datetime, decimal, float, integer, primary_key, string, text, time, timestamp | |
Examples: | |
`rails generate scaffold post` |
Include in gemfile: | |
gem 'pagy' | |
for global access, include in application_controller.rb: | |
include Pagy::Backend | |
and in application_helper.rb: | |
include Pagy::Frontend | |
In controller (eg. BlogPosts), where items define number of items per page: |
# store all seeds inside the folder db/seeds | |
# files are sorted alphabetically before loading them, so we can make sure the files are processed in order | |
# choose the filenames wisely, e.g. something like 0100_operators.rb, 0200_companies.rb, 0300_products.rb ...) | |
# | |
Dir[File.join(Rails.root, 'db', 'seeds', '*.rb')].sort.each { |seed| load seed } |
# Rails | |
# to use globally, put in class ApplicationRecord | |
# before delete/destroy check for restrict dependents | |
# given an object, iterate its associations, and check if the restricted ones are empty or not. | |
def has_no_restrict_dependent? | |
self.class.reflect_on_all_associations.all? do |assoc| | |
( ([:restrict_with_error, :restrict_with_exception].exclude? assoc.options[:dependent]) || | |
(assoc.macro == :has_one && self.send(assoc.name).nil?) || |
## Step 1: remove all history | |
cd <project-folder> | |
rm -rf .git | |
## Step 2: initialize the Git repo | |
git init | |
git add . |
watchman watch-del-all | |
rm -rf $TMPDIR/react-* | |
rm -rf node_modules | |
npm cache clean --force | |
npm install |