README.md in ctws-0.1.12.alpha vs README.md in ctws-0.1.13.alpha

- old
+ new

@@ -34,17 +34,17 @@ This line will mount the engine at `/ws` in the application. Making it accessible at `http://localhost:3000/ws` when the application runs with rails server. It can be whatever you want. ## Engine setup -The engine contains migrations for the `ctws_min_app_version` and `xxx` table which need to be created in the application's database so that the engine's models can query them correctly. +The engine contains migrations for the `ctws_min_app_version` and `xxx` table which need to be created in the application's database so that the engine's models can query them correctly. To copy these migrations into the application run the following command from the Rails App root, then run these migrations: ```bash rails ctws:install:migrations rails db:migrate -``` +``` If you want to revert engine's migrations before removing it. To revert all migrations from blorgh engine you can run code such as: ```bash bin/rails db:migrate SCOPE=ctws VERSION=0 @@ -52,34 +52,34 @@ ### Hook the application `User` model with the engine By default the user model is `User` but you can change it by creating or editing the `ctws.rb` initializer file in `config/initializers` and put this content in it: -```ruby +```ruby Ctws.user_class = "Account" ``` The application `User` model **must have the `email` attribute**. The **`password` is optional** by default a user is validated with password, for `password` validation [`ActiveModel::SecurePassword::InstanceMethodsOnActivation authenticate`](https://apidock.com/rails/v4.2.7/ActiveModel/SecurePassword/InstanceMethodsOnActivation/authenticate) and [`Devise::Models::DatabaseAuthenticatable#valid_password?`](http://www.rubydoc.info/github/plataformatec/devise/Devise%2FModels%2FDatabaseAuthenticatable:valid_password%3F) User instance methods are supported. To opt out the user validation with the password change it by creating or editing the `ctws.rb` initializer file in `config/initializers` and put this content in it: -```ruby +```ruby Ctws.user_validate_with_password = false ``` You can edit your app's required fields for signup by creating or editing the `ctws.rb` initializer file in `config/initializers` and put your strong parameters: -```ruby +```ruby Ctws.user_class_strong_params = [:email, :password, :password_confirmation] ``` ### Set the `JWT` expiry time By default the token expiry time is 24h but you can change it by creating or editing the `ctws.rb` initializer file in `config/initializers` and put this content in it: -```ruby +```ruby Ctws.jwt_expiration_time = 24.hours.from_now ``` <!-- Change the app's models so that they know that they are supposed to act like ctws: @@ -91,10 +91,18 @@ acts_as_ctws end ``` --> +### Response messages in users' locale (i18n) + +In your app set your accepted languages, add to `application.rb`: + +``` +config.i18n.available_locales = %w(en es fr ca) +``` + ## Endpoints | Endpoint | Functionality | Requires Authentication? | | -------------------------------------------------- | -----------------------------------------------: | :-----------------------: | | `GET /ctws/v1/min_app_version` | Get latest minimum app version for all platforms | No | @@ -131,30 +139,30 @@ X-XSS-Protection: 1; mode=block { "data": [ { - "id": 3, + "id": 3, "type": "min_app_version", "attributes": { - "codename": "Second release", - "description": "Second release Description text", - "min_version": "0.0.2", - "platform": "android", - "store_uri": "htttps://fdsafdsafdsaf.cot", + "codename": "Second release", + "description": "Second release Description text", + "min_version": "0.0.2", + "platform": "android", + "store_uri": "htttps://fdsafdsafdsaf.cot", "updated_at": "2017-06-22T17:53:31.252+02:00" } - }, + }, { "type": "min_app_version", - "id": 1, + "id": 1, "attributes": { - "codename": "First Release", - "description": "You need to update your app. You will be redirected to the corresponding store", - "min_version": "0.0.1", - "platform": "ios", - "store_uri": "https://itunes.apple.com/", + "codename": "First Release", + "description": "You need to update your app. You will be redirected to the corresponding store", + "min_version": "0.0.1", + "platform": "ios", + "store_uri": "https://itunes.apple.com/", "updated_at": "2017-06-21T14:29:59.348+02:00" } } ] } @@ -182,14 +190,14 @@ X-XSS-Protection: 1; mode=block { "data": { "type": "user", - "id": 20, + "id": 20, "attributes": { "message": "Account created successfully", - "auth_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyMCwiZXhwIjoxNDk5ODU1MjQ5fQ.H9ljjShWOAv8b9xn9ZLKv-zgmH8xkPe6dkdhH4JrJPw", + "auth_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyMCwiZXhwIjoxNDk5ODU1MjQ5fQ.H9ljjShWOAv8b9xn9ZLKv-zgmH8xkPe6dkdhH4JrJPw", "created_at": "2017-07-11T12:27:27.916+02:00" } } } ``` @@ -269,10 +277,10 @@ ## Tests running `rspec` will run tests and output a report, first run migrations the tests: -```bash +```bash rails db:migrate RAILS_ENV=test rspec ``` ## Contributing