/railsember

Primary LanguageRuby

Railsember app

WARNING, Work in progress until Monday Build Status

rails new railsember
rails webpacker:install  # requires node > 10, yarn
yarn install --check-files
bundle install
rails s

Notes, reminders

Reminders for RoR

Steps

rails generate model User name:string password:string email:string active:boolean password_digest:string

rake db:migrate

rails generate model Session token:string active:boolean user:references

rake db:migrate

General comands

Generate api-only

rails new --api app_name

run

rails server

Test

rails test

or

rake test

Generators

Generate controlers. This is about, with about method

rails generate controller about about

Generate models:

rails generate model Lesson name:string description:text

Model with references

 rails g model dish name:string rating:integer restaurant:references

Generate resource:

rails generate resource entry title:string body:text published:boolean
rails generate resource api/v1/user email:string name:string password:string
rails generate resource api/v1/story title:string body:text published:boolean user:references

Generate serializers

rails g serializer category

jsonapi-rb:

rails generate jsonapi:serializable tag

Check routes:

rails routes

Then:

rake db:migrate

for other envs:

export RAILS_ENV=production
rake db:migrate

Populate the Database

rake db:seed

Curl commands

curl http://localhost:3000/courses
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"title":"xyz","description":"xyz", "published": "false"}' \
  http://localhost:3000/courses
curl -i -X POST -H "Content-Type: application/json" -d  '{"title":"xyz","description":"xyz", "published": "false"}' http://localhost:3000/courses


## Enable access to last commit for heroku

```shell
heroku labs:enable runtime-dyno-metadata -a railsember

Where railsember is the name of the app.

Then we should have: HEROKU_SLUG_COMMIT

rubocop

Running it:

bundle exec rubocop app

Autocorrect:

bundle exec rubocop -A app test
bundle exec rubocop app test

Gen config:

bundle exec rubocop --auto-gen-config