From 2fd428a2d00d51b43881270c2481c9ad1e91a4e6 Mon Sep 17 00:00:00 2001 From: Koichi MATSUMOTO Date: Thu, 14 Nov 2019 23:11:21 +0900 Subject: [PATCH 1/5] modify INSTALL.md correct ruby version, note a necessary to install ImageMagick or GraphicsMagick and add a note about environment variables, etc. --- INSTALL.md | 85 ++++++++++++++++++++++++++++++--------------- config/database.yml | 6 ++-- 2 files changed, 61 insertions(+), 30 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 61ab5d92..95359b77 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -5,7 +5,7 @@ * PostgreSQL * Elasticsearch * Redis -* Ruby version 2.3.0 +* Ruby version 2.5.0 * Rails # Lets Get Started! @@ -31,26 +31,15 @@ echo ‘if which rbenv > /dev/null; then eval “$(rbenv init -)”; fi’ >> ~/ source ~/.bash_profile ``` -Install Ruby 2.3.0 which is required by the app: +Install Ruby 2.5.0 which is required by the app: ``` -rbenv install 2.3.0 -rbenv global 2.3.0 +rbenv install 2.5.0 +rbenv global 2.5.0 ruby -v ``` -**3. Install Rails** - -Installing Rails is really simple: - -``` -gem install rails -v 4.2.4 -rbenv rehash -rails -v -``` - - -**4. Install PostgreSQL** +**3. Install PostgreSQL** ``` brew install postgresql @@ -88,7 +77,7 @@ lunchy start postgres ``` -**5. Install Elasticsearch** +**4. Install Elasticsearch** Where would we be without search? The app uses ElasticSearch 1.7.3 which is a search server - quite simply it’s going to help you find posts and users in the app. @@ -119,7 +108,7 @@ Lets check it is running by visiting [http://localhost:9200](http://localhost:92 } ``` -**6. Install Redis** +**5. Install Redis** Using Homebrew install Redis and then start the server: @@ -128,6 +117,16 @@ brew install redis redis-server ``` +**6. Install ImageMagick or GraphicsMagick** + +``` +brew install imagemagick +``` +or +``` +brew install graphicsmagick +``` + **7. Clone the app** Browse to where you want the app to live and clone app: @@ -141,15 +140,47 @@ Change directory into the stories folder cd stories ``` - -**8. Start the app** +**8. Install the app** First install all the required gems: ``` bundle install ``` -Execute Sidekiq, ElasticSearch and Mailer +Next, Set up environment variables: + +You have to set `SECRET_KEY_BASE` and `STORIES_DATABASE_*` at least. (Using `rake secret` create a value to set) + +``` +STORIES_DATABASE_HOST=db_host +STORIES_DATABASE_PORT=db_port +STORIES_DATABASE_NAME=db_name +STORIES_DATABASE_USER=db_user +STORIES_DATABASE_PASSWORD=db_password +``` + +Also have to set the following values + +``` +MAILER_ADDRESS=localhost +MAILER_PORT=[25|465|587] +MAILER_AUTH=[:plain|:cram-md5|...] +MAILER_USER=user +MAILER_PASS=password +MAILER_DOMAIN=example.com +MAILER_ENABLE_TLS=[true|false] +``` + +As appropriate, set variables for Oauth2 login +The callback addresses to be needed are as below: + +``` +Facebook: https://example.com/users/auth/facebook/callback +Twitter: https://example.com/users/auth/twitter/callback +Google: https://example.com/users/auth/google-oatuh2/callback +``` + +Then Execute Sidekiq, ElasticSearch and Mailer ``` bundle exec sidekiq -q elastic search -q mailer -c 3 ``` @@ -172,7 +203,9 @@ rails server Then browse to [http://localhost:3000](http://localhost:3000) to view the app in all its glory. Wait where is that “Hello World!” moment? Time to create the admin account so we can create some posts… -**9. Create an Admin account** +**9. Update a user as an Admin account** + +Fist, sign up your account and then, Enter the rails console: @@ -180,10 +213,10 @@ Enter the rails console: rails console ``` -Add a new user account replacing your email and password: +Update a user account replacing your email: ``` -Admin.create(email: ‘your@email.com’, password: ‘password’, password_confirmation: ‘password’) +User.update(email: ‘your@email.com’, role: ‘admin’) ``` Close the console: @@ -192,10 +225,6 @@ Close the console: exit ``` -Navigate to the Admin dashboard and enter your email and password: - -[http://localhost:3000/admins/sign_in](http://localhost:3000/admins/sign_in) - You can now... - Write new posts - Feature tags by clicking on the “feature” button when on a tag pages diff --git a/config/database.yml b/config/database.yml index 26519960..794c59a7 100644 --- a/config/database.yml +++ b/config/database.yml @@ -80,8 +80,10 @@ test: # production: <<: *default - database: stories_production - username: stories + database: <%= ENV['STORIES_DATABASE_NAME'] %> + username: <%= ENV['STORIES_DATABASE_USER'] %> + host: <%= ENV['STORIES_DATABASE_HOST'] %> + port: <%= ENV['STORIES_DATABASE_PORT'] %> password: <%= ENV['STORIES_DATABASE_PASSWORD'] %> pool: <%= ENV["DB_POOL"] || ENV['MAX_THREADS'] || 5 %> From 54c3f4bf5d25ba5c8ac8b7f107b23dadb4426e51 Mon Sep 17 00:00:00 2001 From: Koichi MATSUMOTO Date: Thu, 14 Nov 2019 23:20:39 +0900 Subject: [PATCH 2/5] Update ruby version Update ruby version --- .ruby-version | 2 +- INSTALL.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.ruby-version b/.ruby-version index cb1d89f6..d7edb568 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.5.0 \ No newline at end of file +ruby-2.6.5 diff --git a/INSTALL.md b/INSTALL.md index 95359b77..2dd10e7f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -5,7 +5,7 @@ * PostgreSQL * Elasticsearch * Redis -* Ruby version 2.5.0 +* Ruby version 2.6.5 * Rails # Lets Get Started! @@ -31,11 +31,11 @@ echo ‘if which rbenv > /dev/null; then eval “$(rbenv init -)”; fi’ >> ~/ source ~/.bash_profile ``` -Install Ruby 2.5.0 which is required by the app: +Install Ruby 2.6.5 which is required by the app: ``` -rbenv install 2.5.0 -rbenv global 2.5.0 +rbenv install 2.6.5 +rbenv global 2.6.5 ruby -v ``` From 8d89d8daf7db7ccd13d646101b12c1d4973ea757 Mon Sep 17 00:00:00 2001 From: Koichi MATSUMOTO Date: Thu, 14 Nov 2019 23:29:38 +0900 Subject: [PATCH 3/5] update ruby version update ruby version --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index fd89a129..b9a6619b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '2.5.0' +ruby '2.6.5' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '6.0.0' From ec2a4a0582687fa4f9f4537b22e19410ca3d399a Mon Sep 17 00:00:00 2001 From: Koichi MATSUMOTO Date: Thu, 14 Nov 2019 23:33:11 +0900 Subject: [PATCH 4/5] typo typo --- INSTALL.md | 1 + 1 file changed, 1 insertion(+) diff --git a/INSTALL.md b/INSTALL.md index 2dd10e7f..ba715dd6 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -172,6 +172,7 @@ MAILER_ENABLE_TLS=[true|false] ``` As appropriate, set variables for Oauth2 login + The callback addresses to be needed are as below: ``` From 255601df8c556575514a399f3fa14f26ed21bd81 Mon Sep 17 00:00:00 2001 From: Koichi MATSUMOTO Date: Fri, 15 Nov 2019 21:30:00 +0900 Subject: [PATCH 5/5] Update database.yml Add default values --- config/database.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/database.yml b/config/database.yml index 794c59a7..5383b43b 100644 --- a/config/database.yml +++ b/config/database.yml @@ -80,10 +80,10 @@ test: # production: <<: *default - database: <%= ENV['STORIES_DATABASE_NAME'] %> - username: <%= ENV['STORIES_DATABASE_USER'] %> - host: <%= ENV['STORIES_DATABASE_HOST'] %> - port: <%= ENV['STORIES_DATABASE_PORT'] %> + database: <%= ENV['STORIES_DATABASE_NAME'] { "stories_production" } %> + username: <%= ENV['STORIES_DATABASE_USER'] { "stories" } %> + host: <%= ENV['STORIES_DATABASE_HOST'] { "localhost" } %> + port: <%= ENV['STORIES_DATABASE_PORT'] { 5432 } %> password: <%= ENV['STORIES_DATABASE_PASSWORD'] %> pool: <%= ENV["DB_POOL"] || ENV['MAX_THREADS'] || 5 %>