### Install PostgreSQL Client (Bash) Source: https://github.com/restarone/violet_rails/wiki/Deploying-to-EC2-(with-Capistrano) Installs the PostgreSQL client and contrib packages on an Ubuntu system, allowing connection to PostgreSQL servers. ```bash sudo apt update sudo apt install postgresql postgresql-contrib ``` -------------------------------- ### Build and Run Docker Compose Services Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Builds the Docker images defined in docker-compose.yml and starts the services. It also includes commands to create and migrate the database for both the application and test environments, and run specific tests. ```bash docker-compose build docker-compose up docker-compose run --rm app rails db:create docker-compose run --rm test rails db:create docker-compose run --rm app rails db:migrate docker-compose run --rm test rails db:migrate # make sure docker-compose up is working and run this test: docker-compose run --rm test rails test test/controllers/admin/sidekiq_controller_test.rb ``` -------------------------------- ### Build and Run Docker Project Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Builds the Docker images for the project using docker-compose and then starts the application services. The `docker attach` command connects to the main application container's logs. ```bash docker-compose build docker-compose up docker attach solutions_app ``` -------------------------------- ### Clone and Navigate Project Directory Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Clones the violet_rails project from GitHub and navigates into the project directory. This is the initial step to get the project code onto your local machine. ```bash git clone git@github.com:restarone/violet_rails.git cd violet_rails ``` -------------------------------- ### Database Migration and Initial Setup for Violet Rails Source: https://github.com/restarone/violet_rails/wiki/Deploying-to-Heroku This section details the commands to migrate the database on Heroku and access the Heroku console to run generators for setting up the root subdomain and landing page. This is crucial for initial application functionality and user management. ```bash heroku run rake db:migrate heroku console ``` -------------------------------- ### Clone Violet Rails Repository Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Clones the Violet Rails project from the specified Git repository URL. This is the initial step for using the template as a starting point for a new application. ```bash git clone git@github.com:restarone/violet_rails.git ``` -------------------------------- ### Install mobile_client_configuration v1 Plugin in Violet Rails Source: https://github.com/restarone/violet_rails/wiki/Defining-a-Mobile-Client-Configuration-(iOS) This script installs the 'mobile_client_configuration v1' plugin into a specified schema within the Violet Web Console. Ensure you replace 'schema' with your target subdomain. This action creates a new API namespace for the mobile client configuration. ```ruby Apartment::Tenant.switch('schema') { ApiNamespace.create!(name: 'mobile_client_configuration',slug: 'mobile_client_configuration',version: 1,requires_authentication: false,namespace_type: 'create-read-update-delete',properties: { tab_navigation: [ { path: "/", label: "Home" } ] }) } ``` -------------------------------- ### Prepare and Run Test Database Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Commands to create and migrate the test database before running tests. This ensures the test environment is set up correctly. ```bash docker-compose run --rm solutions_test rails db:create docker-compose run --rm solutions_test rails db:migrate ``` -------------------------------- ### Install zlib for rbenv OpenSSL (Bash) Source: https://github.com/restarone/violet_rails/wiki/Deploying-to-EC2-(with-Capistrano) Installs the zlib development library, which may be required to resolve errors when installing OpenSSL for rbenv. ```bash sudo apt-get install libz-dev ``` -------------------------------- ### Install App Dependencies on EC2 (Bash) Source: https://github.com/restarone/violet_rails/wiki/Deploying-to-EC2-(with-Capistrano) Installs necessary system packages, Node.js, npm, rbenv, Ruby, Bundler, Rails, Yarn, and Redis on an Ubuntu EC2 instance. It also configures rbenv and installs Nginx. ```bash sudo apt-get update -y && sudo apt-get upgrade -y sudo apt install curl -y sudo apt install nodejs -y && sudo apt install npm -y sudo apt-get install htop imagemagick build-essential zlib1g-dev openssl libreadline6-dev git-core zlib1g libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf automake libtool bison libgecode-dev -y && sudo apt-get install libpq-dev -y echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc && echo 'eval "$(rbenv init -)"' >> ~/.bashrc git clone https://github.com/sstephenson/rbenv.git ~/.rbenv && git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build source ~/.bashrc rbenv install 2.6.6 && rbenv global 2.6.6 && echo 'gem: --no-ri --no-rdoc' >> ~/.gemrc && source ~/.bashrc && gem install bundler:2.1.4 && gem install rails -v 6.1.3 curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt update -y sudo apt install yarn -y sudo apt install redis-server -y sudo apt-get install nginx -y ``` -------------------------------- ### Access Application and Admin Interface Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Provides the URLs to access the running application and its admin interfaces. It specifies credentials for logging into the admin section. ```bash visit `localhost:80`, `lvh.me:5250` or `localhost:5250` To Login, visit `lvh.me:5250/admin` use the following credentials (created by seeds.rb) user: `violet@rails.com` password: `123456` ``` -------------------------------- ### Precompile Assets Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Precompiles the application's assets, such as JavaScript and CSS, for production use. This is a one-time step and can take a significant amount of time (5-20 minutes). ```bash docker-compose run --rm solutions_app rails assets:precompile ``` -------------------------------- ### Configure and Manage Sidekiq Systemd Service Source: https://github.com/restarone/violet_rails/wiki/Deploying-to-EC2-(with-Capistrano) This snippet shows how to configure the Sidekiq systemd service file, including user, working directory, environment variables, and startup/shutdown commands. It also includes commands to reload the daemon, enable, start, and check the status of the Sidekiq service. Viewing logs is done using 'journalctl'. ```bash [Unit] Description = sidekiq After = network.target [Service] Type = simple User = ubuntu WorkingDirectory = /var/www/violet/current EnvironmentFile = /var/www/violet/.rbenv-vars ExecStart = /home/ubuntu/.rbenv/bin/rbenv exec bundle exec sidekiq -C config/sidekiq.yml ExecStop = ps -ef | grep sidekiq | grep -v grep | awk '{print $2}' | xargs kill -9 TimeoutSec = 15 Restart = always [Install] WantedBy = multi-user.target ``` ```bash sudo systemctl daemon-reload sudo systemctl enable sidekiq.service sudo systemctl start sidekiq.service sudo systemctl status sidekiq.service ``` ```bash journalctl -u sidekiq.service -f ``` -------------------------------- ### Attach to Sidekiq Container for Debugging Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Attaches to the `solutions_sidekiq` Docker container to inspect Sidekiq logs or set breakpoints for debugging background job processing. ```bash docker attach solutions_sidekiq ``` -------------------------------- ### Search Field Helper and Handler Source: https://github.com/restarone/violet_rails/wiki/custom-web-development-guide Provides a helper to render a search field and a JavaScript example for handling search form submissions via AJAX. ```APIDOC ## Searching website pages ### Description This section details how to render a search field using a helper and handle search queries via AJAX. ### Method POST ### Endpoint `/query` (for direct AJAX calls) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **query** (string) - Required - The search term. ### Request Example (Direct AJAX) ```javascript $.ajax({ type: 'POST', url: '/query', data: { query: "test" }, dataType: 'json', success(data) { console.log(data); return false; }, error(data) { console.log(data); } }) ``` ### Response #### Success Response (200) - **search_results** (object) - Contains the search results, potentially including preview content. #### Response Example (Response structure depends on how search results are formatted, but will contain preview content if configured) ```json { "preview_content": "HTML markup for search results" } ``` ### Styling Search Results Each page has a preview content form. Enter your HTML markup there and the API will return it in the response. ``` -------------------------------- ### Run Rails Console Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Opens an interactive Rails console session within the solutions_app Docker container, allowing direct interaction with the application's models and logic. ```bash docker-compose run --rm solutions_app rails c ``` -------------------------------- ### Run Full Test Suite Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Executes the complete test suite for the application. This can be done using a custom script or the standard Rails test runner within Docker. ```bash ./clean_run_tests.sh # or docker-compose run --rm solutions_test rails test # or ./run_tests.sh ``` -------------------------------- ### Display Encrypted Private Key Source: https://github.com/restarone/violet_rails/wiki/Direct‐to‐customer-deployment-using-a-Github-Action Displays the content of the encrypted private key file, which should be copied to the DEPLOY_ID_RSA_ENC GitHub secret. ```bash cat deploy_id_rsa_enc ``` -------------------------------- ### Initial Deployment with Capistrano (Bash) Source: https://github.com/restarone/violet_rails/wiki/Deploying-to-EC2-(with-Capistrano) Executes the Capistrano deployment script for the production environment. This step is expected to fail but sets up the necessary file structure. ```bash bundle exec cap production deploy ``` -------------------------------- ### Connect to PostgreSQL Database Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Connects to the specified PostgreSQL database instance using the provided host, port, database name, and username. This is often a prerequisite for performing database maintenance tasks. ```bash psql -h ec2-3-83-199-128.compute-1.amazonaws.com -p 5432 -d postgres -U postgres ``` -------------------------------- ### Display Public SSH Key Source: https://github.com/restarone/violet_rails/wiki/Direct‐to‐customer-deployment-using-a-Github-Action Prints the content of the public SSH key to the console, which is then used for adding to GitHub deployment keys. ```bash cat ~/.ssh/id_rsa.pub ``` -------------------------------- ### Attach to Application Container for Debugging Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Attaches to the `solutions_app` Docker container to view live logs and enable debugging tools like `byebug` or `pry` when breakpoints are hit. ```bash docker attach solutions_app ``` -------------------------------- ### Deploy to Staging Environment using Capistrano Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Deploys the application to the staging environment. The BRANCH environment variable specifies which branch to deploy. ```bash BRANCH=branch bundle exec cap staging deploy ``` -------------------------------- ### Create PostgreSQL User and Database (SQL/Bash) Source: https://github.com/restarone/violet_rails/wiki/Deploying-to-EC2-(with-Capistrano) SQL commands to create a new PostgreSQL role, set a password, and create a database for the application. The bash command then creates the production database. ```sql CREATE ROLE username; ALTER ROLE username WITH LOGIN; ALTER USER username CREATEDB; ALTER USER username WITH PASSWORD 'passwordhere'; \q ``` ```bash psql -h endpoint.amazonaws.com -p 5432 -U username -d postgres -c 'CREATE DATABASE violet_production' ``` -------------------------------- ### Clean Up Docker Application Container Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Stops and removes the `solutions_app` Docker container, rebuilds the image, and restarts the container. This is useful for cleaning up stale application states and resolving issues related to the container. ```bash docker-compose stop solutions_app \ && docker-compose rm -f solutions_app \ && docker-compose build \ && docker-compose up -d solutions_app ``` -------------------------------- ### Export Public SSH Key Source: https://github.com/restarone/violet_rails/wiki/Direct‐to‐customer-deployment-using-a-Github-Action Appends the generated public SSH key to the authorized_keys file, allowing access using this key. ```bash cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys ``` -------------------------------- ### Create Application Configuration Files (Bash) Source: https://github.com/restarone/violet_rails/wiki/Deploying-to-EC2-(with-Capistrano) Creates empty configuration files in the shared config directory for the Rails application. These files will be populated with specific environment settings. ```bash cd /var/www/violet/shared/config touch cable.yml database.yml secrets.yml storage.yml webpacker.yml sidekiq.yml ``` -------------------------------- ### Run Single Test Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Executes a specific test file or test case within the Rails test suite. Replace `path/to/test` with the actual path to the test file. ```bash docker-compose run --rm solutions_test rails test path/to/test ``` -------------------------------- ### Access Subdomain and Domain Admin Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Details how to access the subdomain admin and the global domain admin interfaces. Subdomain admins manage specific subdomains, while domain admins have broader control. ```bash to access the subdomain admin, visit `lvh.me:5250/admin` or `subdomain.lvh.me:5250/admin` to access domain admin visit `lvh.me:5250/sysadmin` ``` -------------------------------- ### Set Development Environment Variables Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Defines development-specific environment variables by creating a `.env.development` file in the project root. These variables are automatically used when running within Docker. ```bash RAILS_ENV=development DATABASE_HOST=solutions_db DATABASE_USERNAME=postgres DATABASE_PASSWORD=password DATABASE_NAME=r_solutions_development DATABASE_PORT=5432 APP_HOST=localhost REDIS_URL=redis://solutions_redis:6379/12 RACK_TIMEOUT_SERVICE_TIMEOUT=200 ``` -------------------------------- ### Configure Local PostgreSQL Database for Rails Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Temporarily replaces the database.yml configuration to point to a local PostgreSQL database. This is necessary when running parts of the application outside of Docker, such as with Capistrano deployments. ```yaml default: &default adapter: postgresql encoding: unicode # For details on connection pooling, see Rails configuration guide # https://guides.rubyonrails.org/configuring.html#database-pooling pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> development: <<: *default host: localhost port: 5432 database: solutions_development username: postgres password: postgres test: <<: *default host: localhost port: 5432 database: solutions_development username: postgres password: postgres staging: <<: *default host: localhost port: 5432 database: solutions_development username: postgres password: postgres production: <<: *default host: localhost port: 5432 database: solutions_development username: postgres password: postgres ``` -------------------------------- ### Create, Migrate, and Seed Database Source: https://github.com/restarone/violet_rails/wiki/Getting-started-(development-cheatsheet) Executes commands within the solutions_app Docker container to create the database, run migrations, and populate it with seed data. The `db/seeds.rb` file contains the data that will be seeded. ```bash docker-compose run --rm solutions_app rails db:create docker-compose run --rm solutions_app rails db:migrate docker-compose run --rm solutions_app rails db:seed ``` -------------------------------- ### Install rbenv-vars Plugin (Bash) Source: https://github.com/restarone/violet_rails/wiki/Deploying-to-EC2-(with-Capistrano) Clones the rbenv-vars plugin into the rbenv plugins directory, which allows managing environment variables for Ruby applications. ```bash git clone https://github.com/rbenv/rbenv-vars.git $(rbenv root)/plugins/rbenv-vars ``` -------------------------------- ### CSS for Video Element Opacity Transition Source: https://github.com/restarone/violet_rails/wiki/custom-web-development-guide This CSS rule sets the initial opacity of the video element to 0 and defines a transition effect for when the opacity changes. This allows for a smooth fade-in effect when the video starts playing. ```css #video { opacity: 0; transition: opacity 2s ease; } ``` -------------------------------- ### Linking Images with CMS File Link Source: https://github.com/restarone/violet_rails/wiki/custom-web-development-guide This example shows how to embed an image from the CMS into your HTML content using the `cms:file_link` helper. It specifies the file ID, desired output format ('image'), and CSS classes. The output is a standard `` tag with a dynamically generated `src` attribute. ```html
{{ cms:file_link 5, as: image, class:"img-fluid img1" }}
``` -------------------------------- ### Obtain and Renew SSL Certificates with Certbot Source: https://github.com/restarone/violet_rails/wiki/Deploying-to-EC2-(with-Capistrano) This section details how to install Certbot for Nginx and obtain SSL certificates, including wildcard certificates using DNS challenge. It provides commands for manual certificate issuance, renewal, and alternative methods for non-wildcard domains. Ensure the correct domain names and email are used. ```bash sudo apt-get install python3-certbot-nginx sudo certbot certonly --manual --preferred-challenges=dns --email contact@restarone.com --server https://acme-v02.api.letsencrypt.org/directory --agree-tos --manual-public-ip-logging-ok -d "*.restarone.solutions" -d "restarone.solutions" sudo service nginx reload ``` ```bash # run the above script again to renew more info on renewing available here: https://community.letsencrypt.org/t/an-authentication-script-must-be-provided-with-manual-auth-hook/74301/2 ``` ```bash sudo certbot --nginx -d your-domain.com sudo certbot renew ``` ```bash sudo certbot certonly --manual --preferred-challenges=dns --email contact@restarone.com --server https://acme-v02.api.letsencrypt.org/directory --agree-tos --manual-public-ip-logging-ok -d "*.everybodyisdoingdrugs.com" -d "everybodyisdoingdrugs.com" -d "*.everyoneisdoingdrugs.com" -d "everyoneisdoingdrugs.com" ``` -------------------------------- ### Clone and Deploy Violet Rails to Heroku Source: https://github.com/restarone/violet_rails/wiki/Deploying-to-Heroku This snippet outlines the process of cloning the Violet Rails repository, creating or connecting to a Heroku application, and pushing the code to Heroku. It also details the necessary environment variables to be set on Heroku for full functionality, including details about Redis URL configuration. ```bash git clone git@github.com:restarone/violet_rails.git # if you don't have a remote origin, you can run: heroku create # if you have an existing heroku remote origin then connect it: heroku git:remote -a your-app-here git push heroku master APP_HOST=example.com MAILGUN_API_KEY=foo MAILGUN_INGRESS_SIGNING_KEY=foo AWS_ACCESS_KEY_ID=foo AWS_SECRET_ACCESS_KEY=foo AWS_REGION=us-east-1 AWS_BUCKET=example.com REDIS_URL=REDISTOGO_URL ``` -------------------------------- ### External API Connection Example (Ruby) Source: https://github.com/restarone/violet_rails/wiki/API:-Entities,-Form-Rendering,-Interfaces-and-Actions This example shows how to define a plain old Ruby class for an External API Connection in Violet Rails. This class is used to authenticate with and extract data from external systems. It can be triggered via cron or on-demand. ```ruby class MyExternalAPIConnection < Violet::ExternalAPIConnection def connect # Authentication logic here end def extract_data # Data extraction logic here end end ``` -------------------------------- ### Modifying Representation Text for Dropdown Options Source: https://github.com/restarone/violet_rails/wiki/Maintaining-Nikean-story-platform This section provides examples of how to modify the display text (representation text) for options in dropdown menus used on the search page. It targets specific API namespaces (e.g., `story_platform/select/psychedelic_tags`) and shows how to map default values to desired display texts. The examples include handling capitalization and specific terms. ```shell # Some examples of when you need to change representation text # story_platform/select/psychedelic_tags representation: 5-meo-dmt -> representation: 5-MeO-DMT representation: Mdma -> representation: MDMA # story_platform/select/identity_tags representation: Lgbtq2sia+ -> representation: LGBTQ2SIA+ representation: Other identity -> representation: Other # story_platform/select/theme_tags representation: Relationship -> representation: Relationship(s) representation: Ptsd -> representation: PTSD # story_platform/select/reason_tags representation: Other reason -> representation: Other ``` -------------------------------- ### Create New Subdomain (Ruby) Source: https://context7.com/restarone/violet_rails/llms.txt Shows how to programmatically create a new subdomain in Ruby, essential for multi-tenancy. This includes configuring various features like blog, forum, tracking, GraphQL, user signup, and session/purge settings. ```ruby # Create new subdomain (PostgreSQL schema) subdomain = Subdomain.create!( name: "acme", html_title: "Acme Corporation", blog_enabled: true, forum_enabled: true, tracking_enabled: true, graphql_enabled: true, allow_user_self_signup: true, session_timeout_exec: '3.hours', purge_visits_every: 'one_month' ) ``` -------------------------------- ### Call to Actions Helper Source: https://github.com/restarone/violet_rails/wiki/custom-web-development-guide Renders templated forms with reCAPTCHA protection. You can render these forms by their ID. ```APIDOC ## Call to Actions Helper ### Description Renders templated forms with reCAPTCHA protection. You can render these forms by their ID. ### Method Not Applicable (Helper method) ### Endpoint Not Applicable (Helper method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```ruby {{ cms:helper render_call_to_action, 1 }} ``` ### Response Not Applicable (Renders HTML form elements) ``` -------------------------------- ### Switching Tenant Context and Accessing Subdomain Data in Ruby Source: https://context7.com/restarone/violet_rails/llms.txt This snippet demonstrates how to switch to a specific subdomain context using Apartment::Tenant and access tenant-specific data such as users and API namespaces. It also shows how to retrieve the current subdomain's hostname and email address, and how to check storage usage and update subdomain settings. ```ruby Apartment::Tenant.switch('acme') do users = User.all # Only users in 'acme' subdomain namespaces = ApiNamespace.all # Only 'acme' API namespaces end current_subdomain = Subdomain.current hostname = current_subdomain.hostname # "acme.example.com" email = current_subdomain.mailing_address # "acme@example.com" storage_bytes = current_subdomain.storage_used storage_mb = storage_bytes / 1024.0 / 1024.0 current_subdomain.update( after_sign_in_path: '/dashboard', after_sign_up_path: '/welcome', enable_2fa: true # Enforce 2FA for all users ) ``` -------------------------------- ### Active Link Styling Source: https://github.com/restarone/violet_rails/wiki/custom-web-development-guide Adds JavaScript and CSS to highlight the current page's link in the navigation bar. ```APIDOC ## Active links ### Description Adds styling to highlight the active page's link in the navigation bar. ### Method Not Applicable (Client-side script) ### Endpoint Not Applicable (Client-side script) ### Parameters None ### Request Example (Add this script to your `navbar` snippet) ```html ``` ### Response Not Applicable (Modifies existing page elements) ### Styling Update your CSS accordingly: ```css .nav-link.current { color: #13aff0; } ``` ``` -------------------------------- ### Violet Rails Automation API - Fetch Animation Data Source: https://github.com/restarone/violet_rails/wiki/custom-web-development-guide Fetches animation data from an API namespace to be used with a Lottie animation player. ```APIDOC ## Integrating with Violet Rails Automation API ### Description This endpoint allows fetching animation data from a designated API namespace, enabling the use of Lottie animations on your website. ### Method GET ### Endpoint `/api/1/{api_namespace}/describe` *Example:* `/api/1/home_anim_data_desktop/describe` ### Parameters #### Path Parameters - **api_namespace** (string) - Required - The name of the API namespace containing the animation data. #### Query Parameters None #### Request Body None ### Request Example ```js async function loadAnimation() { try { const animationData = await getAnimationData( "/api/1/home_anim_data_desktop/describe" ); const config = { container: document.querySelector(".animation-container"), renderer: "svg", loop: false, autoplay: false, rendererSettings: { progressiveLoad: true, }, animationData: animationData, }; lottie.loadAnimation(config); } catch (error) { console.error(error.message); } } async function getAnimationData(url) { try { const response = await fetch(url); const data = await response.json(); return JSON.parse(data.properties.stringified_json_animation); } catch (error) { console.log(error); } } ``` ### Response #### Success Response (200) - **properties.stringified_json_animation** (string) - A JSON string representing the animation data. #### Response Example ```json { "properties": { "stringified_json_animation": "{\"v\":\"5.12.0\", \"fr\":60, ...}" } } ``` ``` -------------------------------- ### Bootstrap Root Domain and WWW Subdomain Source: https://github.com/restarone/violet_rails/wiki/User-and-domain-setup-scripts Executes Ruby code to bootstrap the root domain and the www subdomain for the application. These calls are necessary to establish the foundational domain structure within the Rails application. ```ruby Subdomain.unsafe_bootstrap_root_domain Subdomain.unsafe_bootstrap_www_subdomain ``` -------------------------------- ### Access Rails Console Source: https://github.com/restarone/violet_rails/wiki/User-and-domain-setup-scripts Provides commands to open a Rails console session. This is essential for running administrative tasks and database migrations. It supports both direct execution and execution within a Docker Compose environment. ```bash rails c ``` ```bash docker-compose run --rm solutions_app rails c ``` -------------------------------- ### Create Global Admin User Source: https://github.com/restarone/violet_rails/wiki/User-and-domain-setup-scripts Command to create a new global administrator user account. This involves specifying the user's email, password, and granting administrative privileges. Ensure you are in a Heroku console session when running this command. ```bash User.create!(email: 'youremail@example.com', password: 'password-here', password_confirmation: 'password-here', global_admin: true, confirmed_at: Time.now, can_manage_users: true, can_access_admin: true) ``` -------------------------------- ### Create User with Full Permissions (Ruby) Source: https://context7.com/restarone/violet_rails/llms.txt Defines how to create a new user with extensive administrative and API access privileges. This includes managing web, analytics, files, email, users, blog, subdomain settings, and full access to all API namespaces and keys. ```ruby # Create user with full permissions admin_user = User.create!( email: 'admin@example.com', password: 'secure_password', can_access_admin: true, can_manage_web: true, can_manage_analytics: true, can_manage_files: true, can_manage_email: true, can_manage_users: true, can_manage_blog: true, can_manage_subdomain_settings: true, can_view_restricted_pages: true, moderator: true, api_accessibility: { api_namespaces: { all_namespaces: { full_access: 'true' } }, api_keys: { full_access: 'true' } } ) ``` -------------------------------- ### GET /cookies/fetch Source: https://github.com/restarone/violet_rails/wiki/localization---i18n Fetches the visitor's locale and cookie acceptance status. This endpoint is useful for understanding user location and their consent to cookie usage. ```APIDOC ## GET /cookies/fetch ### Description Fetches the visitor's locale and cookie acceptance status. This endpoint is useful for understanding user location and their consent to cookie usage. ### Method GET ### Endpoint /cookies/fetch ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "No request body needed for this GET request." } ``` ### Response #### Success Response (200) - **cookies_accepted** (string) - Indicates whether cookies have been accepted by the visitor ('true' or 'false'). - **ahoy_visitor_token** (string) - A unique token identifying the visitor. - **ahoy_visit_token** (string) - A unique token identifying the current visit. - **metadata** (object) - An object containing additional metadata about the visitor. - **ip_address** (string) - The IP address of the visitor. - **country** (string) - The country of the visitor. - **country_code** (string) - The two-letter country code of the visitor. #### Response Example ```json { "cookies_accepted": "true", "ahoy_visitor_token": "dae5544b-9d9a-4b14-a030-c32ceb5c68b8", "ahoy_visit_token": "b8e00bd5-abda-4840-bbac-c91457149a6e", "metadata": { "ip_address": "142.184.42.152", "country": "Canada", "country_code": "CA" } } ``` ``` -------------------------------- ### Render Search Field Helper (Ruby) Source: https://github.com/restarone/violet_rails/wiki/custom-web-development-guide This helper function generates an HTML input field for website search functionality. It is intended to be used within an HTML template. ```ruby {{ cms:helper render_search_field }} ```