|
|
||
|---|---|---|
| src/autogen | ||
| .gitignore | ||
| Dockerfile | ||
| README.MD | ||
| docker-compose.yml | ||
README.MD
REf
https://www.simplethread.com/how-to-create-a-new-rails-7-app-with-tailwind/ https://blog.saeloun.com/2021/11/17/rails-7-added-css-app-generator/
docker compose up -d docker compose exec -ti autogen bash
gem install rails gem update --system 3.5.6 rails new autogen --skip-active-record --skip-bundle --css bulma cd autogen/ Add to Gemfile : bundle add mongoid
change config/mongoid.yaml
development:
# Configure available database clients. (required)
clients:
# Defines the default client. (required)
default:
# Mongoid can connect to a URI accepted by the driver:
uri: mongodb://railszen:railszen@mongo:27017/railszen
# Otherwise define the parameters separately.
# This defines the name of the default database that Mongoid can connect to.
# (required).
# database: autodeploy_development
# Provides the hosts the default client can connect to. Must be an array
# of host:port pairs. (required)
# hosts:
# - localhost:27017
options:
# Note that all options listed below are Ruby driver client options (the mongo gem).
# Please refer to the driver documentation of the version of the mongo gem you are using
# for the most up-to-date list of options.
#
# Change the default write concern. (default = { w: 1 })
# write:
# w: 1
# Change the default read preference. Valid options for mode are: :secondary,
# :secondary_preferred, :primary, :primary_preferred, :nearest
# (default: primary)
# read:
# mode: :secondary_preferred
# tag_sets:
# - use: web
# The name of the user for authentication.
# user: 'user'
# The password of the user for authentication.
# password: 'password'
# The user's database roles.
# roles:
# - 'dbOwner'
# Change the default authentication mechanism. Valid options are: :scram,
# :mongodb_cr, :mongodb_x509, and :plain. Note that all authentication
# mechanisms require username and password, with the exception of :mongodb_x509.
# Default on mongoDB 3.0 is :scram, default on 2.4 and 2.6 is :plain.
# auth_mech: :scram
# The database or source to authenticate the user against.
# (default: the database specified above or admin)
# auth_source: admin
# Force a the driver cluster to behave in a certain manner instead of auto-
# discovering. Can be one of: :direct, :replica_set, :sharded. Set to :direct
# when connecting to hidden members of a replica set.
# connect: :direct
# Changes the default time in seconds the server monitors refresh their status
# via hello commands. (default: 10)
# heartbeat_frequency: 10
# The time in seconds for selecting servers for a near read preference. (default: 0.015)
# local_threshold: 0.015
# The timeout in seconds for selecting a server for an operation. (default: 30)
# server_selection_timeout: 30
# The maximum number of connections in the connection pool. (default: 5)
# max_pool_size: 5
# The minimum number of connections in the connection pool. (default: 1)
# min_pool_size: 1
# The time to wait, in seconds, in the connection pool for a connection
# to be checked in before timing out. (default: 5)
# wait_queue_timeout: 5
# The time to wait to establish a connection before timing out, in seconds.
# (default: 10)
# connect_timeout: 10
# How long to wait for a response for each operation sent to the
# server. This timeout should be set to a value larger than the
# processing time for the longest operation that will be executed
# by the application. Note that this is a client-side timeout;
# the server may continue executing an operation after the client
# aborts it with the SocketTimeout exception.
# (default: nil, meaning no timeout)
# socket_timeout: 5
# The name of the replica set to connect to. Servers provided as seeds that do
# not belong to this replica set will be ignored.
# replica_set: name
# Whether to connect to the servers via ssl. (default: false)
# ssl: true
# The certificate file used to identify the connection against MongoDB.
# ssl_cert: /path/to/my.cert
# The private keyfile used to identify the connection against MongoDB.
# Note that even if the key is stored in the same file as the certificate,
# both need to be explicitly specified.
# ssl_key: /path/to/my.key
# A passphrase for the private key.
# ssl_key_pass_phrase: password
# Whether to do peer certification validation. (default: true)
# ssl_verify: true
# The file containing concatenated certificate authority certificates
# used to validate certs passed from the other end of the connection.
# ssl_ca_cert: /path/to/ca.cert
# Whether to truncate long log lines. (default: true)
# truncate_logs: true
# Configure Mongoid specific options. (optional)
options:
# Application name that is printed to the mongodb logs upon establishing
# a connection in server versions >= 3.4. Note that the name cannot
# exceed 128 bytes. It is also used as the database name if the
# database name is not explicitly defined. (default: nil)
# app_name: MyApplicationName
# Mark belongs_to associations as required by default, so that saving a
# model with a missing belongs_to association will trigger a validation
# error. (default: true)
# belongs_to_required_by_default: true
# Raise an exception when a field is redefined. (default: false)
# duplicate_fields_exception: false
# Include the root model name in json serialization. (default: false)
# include_root_in_json: false
# Include the _type field in serialization. (default: false)
# include_type_for_serialization: false
# Whether to join nested persistence contexts for atomic operations
# to parent contexts by default. (default: false)
# join_contexts: false
# Set the Mongoid and Ruby driver log levels when Mongoid is not using
# Ruby on Rails logger instance. (default: :info)
# log_level: :info
# Preload all models in development, needed when models use
# inheritance. (default: false)
# preload_models: false
# Raise an error when performing a #find and the document is not found.
# (default: true)
raise_not_found_error: false
# Raise an error when defining a scope with the same name as an
# existing method. (default: false)
# scope_overwrite_exception: false
# Use ActiveSupport's time zone in time operations instead of
# the Ruby default time zone. See the time zone section below for
# further information. (default: true)
# use_activesupport_time_zone: true
# Return stored times as UTC. See the time zone section below for
# further information. Most applications should not use this option.
# (default: false)
# use_utc: false
# (Deprecated) In MongoDB 4.0 and earlier, set whether to create
# indexes in the background by default. (default: false)
# background_indexing: false
test:
clients:
default:
uri: mongodb://railszen:railszen@mongo:27017/railszen
# database: autodeploy_test
# hosts:
# - localhost:27017
options:
read:
mode: :primary
max_pool_size: 1
bin/rails g mongoid:config edit config/database.yml and update database info config/application.rb add config.hosts << "autoinstall.msi.stef.lan"
bundle add hotwire-livereload --group development ./bin/rails generate controller Public index --no-helper --no-controller-specs
bin/rails g scaffold Script name:string stage:string lang:string content:text lock:boolean description:text bin/rails g scaffold Site name:string domain:string gateway:string nameserver:string network:string netmask:string
bin/rails s -b 0.0.0.0
Add devise
root@autogen:/usr/src/autogen# bundle add devise
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
root@autogen:/usr/src/autogen# rails generate devise:install
create config/initializers/devise.rb
create config/locales/devise.en.yml
===============================================================================
Depending on your application's configuration some manual setup may be required:
1. Ensure you have defined default url options in your environments files. Here
is an example of default_url_options appropriate for a development environment
in config/environments/development.rb:
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
In production, :host should be set to the actual host of your application.
* Required for all applications. *
2. Ensure you have defined root_url to *something* in your config/routes.rb.
For example:
root to: "home#index"
* Not required for API-only Applications *
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
For example:
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
* Not required for API-only Applications *
4. You can copy Devise views (for customization) to your app by running:
rails g devise:views
* Not required *
===============================================================================
root@autogen:/usr/src/autogen# rails generate devise User
invoke mongoid
create app/models/user.rb
invoke test_unit
create test/models/user_test.rb
create test/fixtures/users.yml
insert app/models/user.rb
insert app/models/user.rb
route devise_for :users
test save
{
_id: ObjectId('65aab0004d003d00837c11b1'),
login: 'stef',
updated_at: ISODate('2024-02-07T20:21:48.310Z'),
created_at: ISODate('2024-01-19T17:23:12.358Z'),
name: 'me',
sshpubkey: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC14slyp/JGv9iqLH4D94x+7v4PB/ec0YbLUPexdBip6OJaflbmp3s25WJ+oyO6U78Ee0jZUZt0TapYozyNx9UksP9JhirwKeNJnQSzSX0RKc6kQffoCgWHZmnzuoalEzaE7XyH+K8wP+hKi052ak9yR7XWDp6CG3V1Qpyq80VD1XNUzEL2xkITGQ6KojxrOJ1O0A9ISRu1t85Ul2N0syIylE2Ukvns1/NkArhC2g8N8T5XxPq39AUH78A3I0/kHowIzW9BpPVwim0tJTLSVNnVqq1NPG+gi1XvrXKzO/jb4kT01tnMG9vKcYqdH4g0y01ADEcCgMo1jGAjwq6gPLqT imported-openssh-key',
encpassword: '$6$012345678$7Mu8dw7L8ye6pf8VYKGrTiHThM3LVnVnOkJNVz8DmVaK4YpAij7zbewaQ4/OYkClPHG1us0t7EshEI.dmayWs.'
}