demo-rails-forest-admin
Demonstration of Ruby on Rails with Forest Admin web service
https://github.com/joelparkerhenderson/demo-rails-forest-admin
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (7.2%) to scientific vocabulary
Repository
Demonstration of Ruby on Rails with Forest Admin web service
Basic Info
- Host: GitHub
- Owner: joelparkerhenderson
- Language: Ruby
- Default Branch: main
- Size: 52.7 KB
Statistics
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Demo Rails app
Demonstration of:
Ruby on Rails web framework
Forest Admin web service
Postgres relational database
SQLite lightweight database
Prepare
If you use the command asdf to version:
sh
asdf global ruby latest
asdf global postgres latest
Have Ruby 3?
sh
ruby --version
Have Rails 7?
sh
gem list rails
Have Postgres 14?
sh
postgres --version
Have SQLite 3?
sh
sqlite3 --version
New demo
Create a new demo:
sh
rails new demo_rails_forest_admin --database=postgresql
cd demo_rails_forest_admin
git add -A && git commit -am "Run rails new demo_rails_forest_admin --database=postgresql"
If you use asdf then set Ruby and Postgres
sh
asdf local ruby latest
asdf local postgres latest
asdf install
git add -A && git commit -am "Add asdf with local ruby latest and local postgres latest"
Verify you can use the Postgres control command pg_ctl:
pg_ctl stop
pg_ctl start
Add gem dotenv-rails
Add to Gemfile:
```ruby
Environment variables
gem "dotenv-rails", groups: [:development, :test] ```
Run:
```sh git add -A && git commit -am "Add gem dotenv-rails"
bundle git add -A && git commit -am "Run bundle" ```
Append to file .gitgnore:
```gitignore
Ignore dotenv environment variable file.
/.env ```
Run:
sh
git add -A && git commit -am "Add .gitignore rule for dotenv file /.env"
touch .env
Create the database access
For a demo app, we prefer to set database access via environment variables.
For a production app, we prefer to set database access via ephemeral controls such as via Hashicorp Vault.
For a naming convention, we prefer explicit database access environment variables:
The database server name: POSTGRES
The database server object: USER
The role identifier: DEMORAILSFOREST_ADMIN
The role attribute: USERNAME or PASSWORD
The word FOR and the runtime environment: DEVELOPMENT or TEST or PRODUCTION
For our password, we prefer to generate a strong random password, such as a strong random 32-digit number:
sh
printf "%s\n" $(LC_ALL=C < /dev/urandom tr -dc '[:digit:]' | head -c32)
Edit file .env to set the database access enviornment variables and the generated passwords:
```sh POSTGRESUSERDEMORAILSFORESTADMINUSERNAMEFORDEVELOPMENT=demorailsforestadmin POSTGRESUSERDEMORAILSFORESTADMINPASSWORDFOR_DEVELOPMENT=11053635016261456248726591454979
POSTGRESUSERDEMORAILSFORESTADMINUSERNAMEFORTEST=demorailsforestadmin POSTGRESUSERDEMORAILSFORESTADMINPASSWORDFOR_TEST=82138770260839801404701988766919
POSTGRESUSERDEMORAILSFORESTADMINUSERNAMEFORPRODUCTION=demorailsforestadmin POSTGRESUSERDEMORAILSFORESTADMINUSERNAMEFOR_PRODUCTION=59637922222719767183438989864425 ```
Create the database role and enter the password for development:
sh
createuser --username=postgres --pwprompt --createdb demo_rails_forest_admin
Configure the database access
Edit file config/database.yml to add each section's username and password:
```yaml development: <<: *default database: demorailsforestadmindevelopment username: <%= ENV["POSTGRESUSERDEMORAILSFORESTADMINUSERNAMEFORDEVELOPMENT"] %> password: <%= ENV["POSTGRESUSERDEMORAILSFORESTADMINUSERNAMEFORDEVELOPMENT"] %> …
test: <<: *default database: demorailsforestadmintest username: <%= ENV["POSTGRESUSERDEMORAILSFORESTADMINUSERNAMEFORTEST"] %> password: <%= ENV["POSTGRESUSERDEMORAILSFORESTADMINUSERNAMEFORTEST"] %> …
production: <<: *default database: demorailsforestadminproduction username: <%= ENV["POSTGRESUSERDEMORAILSFORESTADMINUSERNAMEFORPRODUCTION"] %> password: <%= ENV["POSTGRESUSERDEMORAILSFORESTADMINUSERNAMEFORPRODUCTION"] %> … ```
RUn:
sh
git add -A && git commit -am "Add database access usernames and passwords"
Run:
Pepare the database
sh
bin/rails db:prepare
Output should include:
sh
Created database 'demo_rails_forest_admin_development'
Created database 'demo_rails_forest_admin_test'
Launch the server
Launch the Rails Puma server:
sh
bin/rails server
Output should include:
sh
Puma starting in single mode...
* Listening on http://127.0.0.1:3000
Browse http://127.0.0.1:3000 and you should see the Rails welcome page.
Enable Postgres UUID primary keys
Enable Postgres UUID primary keys and their functions via pgcrypto:
sh
bin/rails generate migration EnableExtensionPgcrypto
Edit file db/migration/*_enable_extension_pgcrypto:
ruby
class EnableExtensionPgcrypto < ActiveRecord::Migration[7.0]
def change
enable_extension 'pgcrypto'
end
end
sh
git add -A && git commit -am "Add db migration to enable extension pgcrypto, then migrate"
bin/rails db:migrate
git add -A && git commit -am "Run rails db:migrate"
Create file config/initializers/generators.rb:
ruby
Rails.application.config.generators do |g|
g.orm :active_record, primary_key_type: :uuid
end
sh
git add -A && git commit -am "Add generators ORM primary key type UUID"
Install ActiveStorage
Add to Gemfile:
ruby
gem "image_processing", ">= 1.2"
Run:
```sh git add -A && git commit -am "Add gem image_processing"
bundle git add -A && git commit -am "Run bundle"
bin/rails activestorage:install git add -A && git commit -am "Run rails activestorage:install"
bin/rails db:migrate git add -A && git commit -am "Run rails db:migrate" ```
The project now has a new database migration file db/migrate/*_create_active_storage_tables.active_storage.rb.
Add scaffolds for users, groups, memberships
Generate scaffolds for our demo resources, which are users, groups, memberships.
```sh bin/rails generate scaffold User name:string description:string bin/rails db:migrate git add -A && git commit -am "Run rails generate scaffold User, then db:migrate"
bin/rails generate scaffold Group name:string description:string bin/rails db:migrate git add -A && git commit -am "Run rails generate scaffold Group, then db:migrate"
bin/rails generate scaffold Membership group:references user:references bin/rails db:migrate git add -A && git commit -am "Run rails generate scaffold Membership, then db:migrate" ```
Edit file app/models/user.rb
ruby
class User < ApplicationRecord
has_many :memberships
has_many :groups, through: :memberships
end
sh
git add -A && git commit -am "Add user associations"
Edit file app/models/group.rb
ruby
class Group < ApplicationRecord
has_many :memberships
has_many :users, through: :memberships
end
sh
git add -A && git commit -am "Add group associations"
Add root route
Edit file config/routes:
ruby
root "users#index"
sh
git add -A && git commit -am "Add root route"
Add Devise authentication
Add to Gemfile:
```ruby
Devise authentication
gem "devise" ```
```sh git add -A && git commit -am "Add gem devise"
bundle git add -A && git commit -am "Run bundle"
rails generate devise:install git add -A && git commit -am "Run rails generate devise:install"
rails generate devise User git add -A && git commit -am "Run rails generate generate devise User"
rails db:migrate git add -A && git commit -am "Run rails db:migrate" ```
Owner
- Name: Joel Parker Henderson
- Login: joelparkerhenderson
- Kind: user
- Location: California
- Website: http://www.joelparkerhenderson.com
- Repositories: 319
- Profile: https://github.com/joelparkerhenderson
Software developer. Technology consultant. Creator of GitAlias.com, NumCommand.com, SixArm.com, and many open source projects.
Citation (CITATION.cff)
cff-version: 1.2.0
title: Demo Rails app
message: >-
If you use this work and you want to cite it,
then you can use the metadata from this file.
type: software
authors:
- given-names: Joel Parker
family-names: Henderson
email: joel@joelparkerhenderson.com
affiliation: joelparkerhenderson.com
orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
- type: url
value: 'https://github.com/joelparkerhenderson/demo-rails-forest-admin/'
description: Demo Rails app
repository-code: 'https://github.com/joelparkerhenderson/demo-rails-forest-admin/'
abstract: >-
Demo Rails app
license: See license file
GitHub Events
Total
Last Year
Committers
Last synced: about 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Joel Parker Henderson | j****l@j****m | 23 |
Committer Domains (Top 20 + Academic)
Dependencies
- capybara >= 0 development
- dotenv-rails >= 0 development
- selenium-webdriver >= 0 development
- web-console >= 0 development
- webdrivers >= 0 development
- bootsnap >= 0
- devise >= 0
- image_processing ~> 1.2
- importmap-rails >= 0
- jbuilder >= 0
- pg ~> 1.1
- puma ~> 5.0
- rails ~> 7.0.3
- redis ~> 4.0
- sprockets-rails >= 0
- stimulus-rails >= 0
- turbo-rails >= 0
- actioncable 7.0.3.1
- actionmailbox 7.0.3.1
- actionmailer 7.0.3.1
- actionpack 7.0.3.1
- actiontext 7.0.3.1
- actionview 7.0.3.1
- activejob 7.0.3.1
- activemodel 7.0.3.1
- activerecord 7.0.3.1
- activestorage 7.0.3.1
- activesupport 7.0.3.1
- addressable 2.8.0
- bcrypt 3.1.18
- bindex 0.8.1
- bootsnap 1.12.0
- builder 3.2.4
- bundler 2.3.17
- capybara 3.37.1
- childprocess 4.1.0
- concurrent-ruby 1.1.10
- crass 1.0.6
- debug 1.6.1
- devise 4.8.1
- digest 3.1.0
- dotenv 2.7.6
- dotenv-rails 2.7.6
- erubi 1.10.0
- ffi 1.15.5
- globalid 1.0.0
- i18n 1.11.0
- image_processing 1.12.2
- importmap-rails 1.1.2
- io-console 0.5.11
- irb 1.4.1
- jbuilder 2.11.5
- loofah 2.18.0
- mail 2.7.1
- marcel 1.0.2
- matrix 0.4.2
- method_source 1.0.0
- mini_magick 4.11.0
- mini_mime 1.1.2
- minitest 5.16.2
- msgpack 1.5.3
- net-imap 0.2.3
- net-pop 0.1.1
- net-protocol 0.1.3
- net-smtp 0.3.1
- nio4r 2.5.8
- nokogiri 1.13.7
- orm_adapter 0.5.0
- pg 1.4.1
- public_suffix 4.0.7
- puma 5.6.4
- racc 1.6.0
- rack 2.2.4
- rack-test 2.0.2
- rails 7.0.3.1
- rails-dom-testing 2.0.3
- rails-html-sanitizer 1.4.3
- railties 7.0.3.1
- rake 13.0.6
- redis 4.7.1
- regexp_parser 2.5.0
- reline 0.3.1
- responders 3.0.1
- rexml 3.2.5
- ruby-vips 2.1.4
- rubyzip 2.3.2
- selenium-webdriver 4.3.0
- sprockets 4.1.1
- sprockets-rails 3.4.2
- stimulus-rails 1.0.4
- strscan 3.0.3
- thor 1.2.1
- timeout 0.3.0
- turbo-rails 1.1.1
- tzinfo 2.0.4
- warden 1.2.9
- web-console 4.2.0
- webdrivers 5.0.0
- websocket 1.2.9
- websocket-driver 0.7.5
- websocket-extensions 0.1.5
- xpath 3.2.0
- zeitwerk 2.6.0