13 |
14 | Elect is a platform focused on the user that is looking for a candidate for congress
15 | according to the political spectrum.
16 |
17 | <%= image_tag "side.png", class: 'img-about'%>
18 |
19 | We provide a quiz with questions of different social and economic subjects in which,
20 | according to the answers, the political spectrum will be built and candidates that fit on
21 | the ideology will be shown as results, making easier to the user to choose a candidate to vote.
22 |
You're inclined to <%= current_user.orientation %> politics!
10 |
11 |
12 |
13 |
14 |
15 | ">
16 |
17 |
18 | ">
19 |
20 |
21 | ">
22 |
23 |
24 |
25 |
26 |
27 |
Left-wing
28 |
29 |
30 |
Center
31 |
32 |
33 |
Right
34 |
35 |
36 |
37 |
38 |
39 | <% if @users.orientation == "left-wing"%>
40 |
Left-wing politics describes the range of political ideologies that support and seek to achieve social equality and egalitarianism, often in opposition to social hierarchy. Left-wing politics typically involve a concern for those in society whom its adherents perceive as disadvantaged relative to others as well as a belief that there are unjustified inequalities that need to be reduced or abolished. Left-wing politics are also associated with popular or state control of major political and economic institutions.
Right-wing politics describes the range of political ideologies that view certain social orders and hierarchies as inevitable, natural, normal, or desirable, typically supporting this position on the basis of natural law, economics, authority, property or tradition. Hierarchy and inequality may be seen as natural results of traditional social differences or competition in market economies.
Centrism is a political outlook or position involving acceptance or support of a balance of social equality and a degree of social hierarchy while opposing political changes that would result in a significant shift of society strongly to the left or the right.
102 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'bundle' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "rubygems"
12 |
13 | m = Module.new do
14 | module_function
15 |
16 | def invoked_as_script?
17 | File.expand_path($0) == File.expand_path(__FILE__)
18 | end
19 |
20 | def env_var_version
21 | ENV["BUNDLER_VERSION"]
22 | end
23 |
24 | def cli_arg_version
25 | return unless invoked_as_script? # don't want to hijack other binstubs
26 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27 | bundler_version = nil
28 | update_index = nil
29 | ARGV.each_with_index do |a, i|
30 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31 | bundler_version = a
32 | end
33 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34 | bundler_version = $1
35 | update_index = i
36 | end
37 | bundler_version
38 | end
39 |
40 | def gemfile
41 | gemfile = ENV["BUNDLE_GEMFILE"]
42 | return gemfile if gemfile && !gemfile.empty?
43 |
44 | File.expand_path("../Gemfile", __dir__)
45 | end
46 |
47 | def lockfile
48 | lockfile =
49 | case File.basename(gemfile)
50 | when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51 | else "#{gemfile}.lock"
52 | end
53 | File.expand_path(lockfile)
54 | end
55 |
56 | def lockfile_version
57 | return unless File.file?(lockfile)
58 | lockfile_contents = File.read(lockfile)
59 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60 | Regexp.last_match(1)
61 | end
62 |
63 | def bundler_requirement
64 | @bundler_requirement ||=
65 | env_var_version || cli_arg_version ||
66 | bundler_requirement_for(lockfile_version)
67 | end
68 |
69 | def bundler_requirement_for(version)
70 | return "#{Gem::Requirement.default}.a" unless version
71 |
72 | bundler_gem_version = Gem::Version.new(version)
73 |
74 | requirement = bundler_gem_version.approximate_recommendation
75 |
76 | return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0")
77 |
78 | requirement += ".a" if bundler_gem_version.prerelease?
79 |
80 | requirement
81 | end
82 |
83 | def load_bundler!
84 | ENV["BUNDLE_GEMFILE"] ||= gemfile
85 |
86 | activate_bundler
87 | end
88 |
89 | def activate_bundler
90 | gem_error = activation_error_handling do
91 | gem "bundler", bundler_requirement
92 | end
93 | return if gem_error.nil?
94 | require_error = activation_error_handling do
95 | require "bundler/version"
96 | end
97 | return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98 | warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99 | exit 42
100 | end
101 |
102 | def activation_error_handling
103 | yield
104 | nil
105 | rescue StandardError, LoadError => e
106 | e
107 | end
108 | end
109 |
110 | m.load_bundler!
111 |
112 | if m.invoked_as_script?
113 | load Gem.bin_path("bundler", "bundle")
114 | end
115 |
--------------------------------------------------------------------------------
/bin/dev:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | if ! foreman version &> /dev/null
4 | then
5 | echo "Installing foreman..."
6 | gem install foreman
7 | fi
8 |
9 | foreman start -f Procfile.dev "$@"
10 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | APP_PATH = File.expand_path("../config/application", __dir__)
3 | require_relative "../config/boot"
4 | require "rails/commands"
5 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require_relative "../config/boot"
3 | require "rake"
4 | Rake.application.run
5 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require "fileutils"
3 |
4 | # path to your application root.
5 | APP_ROOT = File.expand_path("..", __dir__)
6 |
7 | def system!(*args)
8 | system(*args) || abort("\n== Command #{args} failed ==")
9 | end
10 |
11 | FileUtils.chdir APP_ROOT do
12 | # This script is a way to set up or update your development environment automatically.
13 | # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14 | # Add necessary setup steps to this file.
15 |
16 | puts "== Installing dependencies =="
17 | system! "gem install bundler --conservative"
18 | system("bundle check") || system!("bundle install")
19 |
20 | # puts "\n== Copying sample files =="
21 | # unless File.exist?("config/database.yml")
22 | # FileUtils.cp "config/database.yml.sample", "config/database.yml"
23 | # end
24 |
25 | puts "\n== Preparing database =="
26 | system! "bin/rails db:prepare"
27 |
28 | puts "\n== Removing old logs and tempfiles =="
29 | system! "bin/rails log:clear tmp:clear"
30 |
31 | puts "\n== Restarting application server =="
32 | system! "bin/rails restart"
33 | end
34 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require_relative "config/environment"
4 |
5 | run Rails.application
6 | Rails.application.load_server
7 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require_relative "boot"
2 |
3 | require "rails/all"
4 |
5 | # Require the gems listed in Gemfile, including any gems
6 | # you've limited to :test, :development, or :production.
7 | Bundler.require(*Rails.groups)
8 |
9 | module Elect
10 | class Application < Rails::Application
11 | config.generators do |generate|
12 | generate.assets false
13 | generate.helper false
14 | generate.test_framework :test_unit, fixture: false
15 | end
16 | # Initialize configuration defaults for originally generated Rails version.
17 | config.load_defaults 7.0
18 |
19 | # Configuration for the application, engines, and railties goes here.
20 | #
21 | # These settings can be overridden in specific environments using the files
22 | # in config/environments, which are processed later.
23 | #
24 | # config.time_zone = "Central Time (US & Canada)"
25 | # config.eager_load_paths << Rails.root.join("extras")
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
2 |
3 | require "bundler/setup" # Set up gems listed in the Gemfile.
4 | require "bootsnap/setup" # Speed up boot time by caching expensive operations.
5 |
--------------------------------------------------------------------------------
/config/cable.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: async
3 |
4 | test:
5 | adapter: test
6 |
7 | production:
8 | adapter: redis
9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10 | channel_prefix: elect_production
11 |
--------------------------------------------------------------------------------
/config/credentials.yml.enc:
--------------------------------------------------------------------------------
1 | F+olU/jzPZEIXyu9q5kuOQ6ip7rg7x2jK/KeIgU2cq41Zpp9TJYtI4xivhOwgXacgGSHsI1+hmr9jwAf1aEAIIb1jeqrS9YtwfX66n61gN2IOXQnBr1Lil+XXp+otd7Tdas47T6cmDCT7xig4a/Jzzq0iPun+ezPrNTG+9NDyC1w0qQMCbdc1NGpC2QV9ZaP6J1fZ+XBN7McmuX3txSVt7j3UcACvBvmtIiaDR6UpkfPCwcYguUKKaIx6icjSmPYDdANAhD2YoCJbBYeMUhH4APNbD61n6s7pFb82mjDdYWGIgtqrqpKTmrXgUnEzTmSTztbxnJjwPuNmyKxjiKm/C5JGu0MeZQaovU4E4K1RmBkqVYj7RPhDWmkuEDO6kUFjOdcjUl93miAr94MNIFhBtf6BxIihifFh0Gb--ZvSJhXBE9L5ZaeEL--o1c6ydBCyFQ4H0MK872VIA==
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # PostgreSQL. Versions 9.3 and up are supported.
2 | #
3 | # Install the pg driver:
4 | # gem install pg
5 | # On macOS with Homebrew:
6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7 | # On macOS with MacPorts:
8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9 | # On Windows:
10 | # gem install pg
11 | # Choose the win32 build.
12 | # Install PostgreSQL and put its /bin directory on your path.
13 | #
14 | # Configure Using Gemfile
15 | # gem "pg"
16 | #
17 | default: &default
18 | adapter: postgresql
19 | encoding: unicode
20 | # For details on connection pooling, see Rails configuration guide
21 | # https://guides.rubyonrails.org/configuring.html#database-pooling
22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23 |
24 | development:
25 | <<: *default
26 | database: elect_development
27 |
28 | # The specified database role being used to connect to postgres.
29 | # To create additional roles in postgres see `$ createuser --help`.
30 | # When left blank, postgres will use the default role. This is
31 | # the same name as the operating system user running Rails.
32 | #username: elect
33 |
34 | # The password associated with the postgres role (username).
35 | #password:
36 |
37 | # Connect on a TCP socket. Omitted by default since the client uses a
38 | # domain socket that doesn't need configuration. Windows does not have
39 | # domain sockets, so uncomment these lines.
40 | #host: localhost
41 |
42 | # The TCP port the server listens on. Defaults to 5432.
43 | # If your server runs on a different port number, change accordingly.
44 | #port: 5432
45 |
46 | # Schema search path. The server defaults to $user,public
47 | #schema_search_path: myapp,sharedapp,public
48 |
49 | # Minimum log levels, in increasing order:
50 | # debug5, debug4, debug3, debug2, debug1,
51 | # log, notice, warning, error, fatal, and panic
52 | # Defaults to warning.
53 | #min_messages: notice
54 |
55 | # Warning: The database defined as "test" will be erased and
56 | # re-generated from your development database when you run "rake".
57 | # Do not set this db to the same as development or production.
58 | test:
59 | <<: *default
60 | database: elect_test
61 |
62 | # As with config/credentials.yml, you never want to store sensitive information,
63 | # like your database password, in your source code. If your source code is
64 | # ever seen by anyone, they now have access to your database.
65 | #
66 | # Instead, provide the password or a full connection URL as an environment
67 | # variable when you boot the app. For example:
68 | #
69 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
70 | #
71 | # If the connection URL is provided in the special DATABASE_URL environment
72 | # variable, Rails will automatically merge its configuration values on top of
73 | # the values provided in this file. Alternatively, you can specify a connection
74 | # URL environment variable explicitly:
75 | #
76 | # production:
77 | # url: <%= ENV["MY_APP_DATABASE_URL"] %>
78 | #
79 | # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
80 | # for a full overview on how database connection configuration can be specified.
81 | #
82 | production:
83 | <<: *default
84 | database: elect_production
85 | username: elect
86 | password: <%= ENV["ELECT_DATABASE_PASSWORD"] %>
87 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require_relative "application"
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | require "active_support/core_ext/integer/time"
2 |
3 | Rails.application.configure do
4 | config.action_mailer.default_url_options = { host: "http://localhost:3000" }
5 | # Settings specified here will take precedence over those in config/application.rb.
6 |
7 | # In the development environment your application's code is reloaded any time
8 | # it changes. This slows down response time but is perfect for development
9 | # since you don't have to restart the web server when you make code changes.
10 | config.cache_classes = false
11 |
12 | # Do not eager load code on boot.
13 | config.eager_load = false
14 |
15 | # Show full error reports.
16 | config.consider_all_requests_local = true
17 |
18 | # Enable server timing
19 | config.server_timing = true
20 |
21 | # Enable/disable caching. By default caching is disabled.
22 | # Run rails dev:cache to toggle caching.
23 | if Rails.root.join("tmp/caching-dev.txt").exist?
24 | config.action_controller.perform_caching = true
25 | config.action_controller.enable_fragment_cache_logging = true
26 |
27 | config.cache_store = :memory_store
28 | config.public_file_server.headers = {
29 | "Cache-Control" => "public, max-age=#{2.days.to_i}"
30 | }
31 | else
32 | config.action_controller.perform_caching = false
33 |
34 | config.cache_store = :null_store
35 | end
36 |
37 | # Store uploaded files on the local file system (see config/storage.yml for options).
38 | config.active_storage.service = :cloudinary
39 |
40 | # Don't care if the mailer can't send.
41 | config.action_mailer.raise_delivery_errors = false
42 |
43 | config.action_mailer.perform_caching = false
44 |
45 | # Print deprecation notices to the Rails logger.
46 | config.active_support.deprecation = :log
47 |
48 | # Raise exceptions for disallowed deprecations.
49 | config.active_support.disallowed_deprecation = :raise
50 |
51 | # Tell Active Support which deprecation messages to disallow.
52 | config.active_support.disallowed_deprecation_warnings = []
53 |
54 | # Raise an error on page load if there are pending migrations.
55 | config.active_record.migration_error = :page_load
56 |
57 | # Highlight code that triggered database queries in logs.
58 | config.active_record.verbose_query_logs = true
59 |
60 | # Suppress logger output for asset requests.
61 | config.assets.quiet = true
62 |
63 | # Raises error for missing translations.
64 | # config.i18n.raise_on_missing_translations = true
65 |
66 | # Annotate rendered view with file names.
67 | # config.action_view.annotate_rendered_view_with_filenames = true
68 |
69 | # Uncomment if you wish to allow Action Cable access from any origin.
70 | # config.action_cable.disable_request_forgery_protection = true
71 | end
72 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | require "active_support/core_ext/integer/time"
2 |
3 | Rails.application.configure do
4 | config.action_mailer.default_url_options = { host: "http://TODO_PUT_YOUR_DOMAIN_HERE" }
5 | # Settings specified here will take precedence over those in config/application.rb.
6 |
7 | # Code is not reloaded between requests.
8 | config.cache_classes = true
9 |
10 | # Eager load code on boot. This eager loads most of Rails and
11 | # your application in memory, allowing both threaded web servers
12 | # and those relying on copy on write to perform better.
13 | # Rake tasks automatically ignore this option for performance.
14 | config.eager_load = true
15 |
16 | # Full error reports are disabled and caching is turned on.
17 | config.consider_all_requests_local = false
18 | config.action_controller.perform_caching = true
19 |
20 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
21 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
22 | # config.require_master_key = true
23 |
24 | # Disable serving static files from the `/public` folder by default since
25 | # Apache or NGINX already handles this.
26 | config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
27 |
28 | # Compress CSS using a preprocessor.
29 | # config.assets.css_compressor = :sass
30 |
31 | # Do not fallback to assets pipeline if a precompiled asset is missed.
32 | config.assets.compile = false
33 |
34 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
35 | # config.asset_host = "http://assets.example.com"
36 |
37 | # Specifies the header that your server uses for sending files.
38 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
39 | # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
40 |
41 | # Store uploaded files on the local file system (see config/storage.yml for options).
42 | config.active_storage.service = :cloudinary
43 |
44 | # Mount Action Cable outside main process or domain.
45 | # config.action_cable.mount_path = nil
46 | # config.action_cable.url = "wss://example.com/cable"
47 | # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
48 |
49 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
50 | # config.force_ssl = true
51 |
52 | # Include generic and useful information about system operation, but avoid logging too much
53 | # information to avoid inadvertent exposure of personally identifiable information (PII).
54 | config.log_level = :info
55 |
56 | # Prepend all log lines with the following tags.
57 | config.log_tags = [ :request_id ]
58 |
59 | # Use a different cache store in production.
60 | # config.cache_store = :mem_cache_store
61 |
62 | # Use a real queuing backend for Active Job (and separate queues per environment).
63 | # config.active_job.queue_adapter = :resque
64 | # config.active_job.queue_name_prefix = "elect_production"
65 |
66 | config.action_mailer.perform_caching = false
67 |
68 | # Ignore bad email addresses and do not raise email delivery errors.
69 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
70 | # config.action_mailer.raise_delivery_errors = false
71 |
72 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
73 | # the I18n.default_locale when a translation cannot be found).
74 | config.i18n.fallbacks = true
75 |
76 | # Don't log any deprecations.
77 | config.active_support.report_deprecations = false
78 |
79 | # Use default logging formatter so that PID and timestamp are not suppressed.
80 | config.log_formatter = ::Logger::Formatter.new
81 |
82 | # Use a different logger for distributed setups.
83 | # require "syslog/logger"
84 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
85 |
86 | if ENV["RAILS_LOG_TO_STDOUT"].present?
87 | logger = ActiveSupport::Logger.new(STDOUT)
88 | logger.formatter = config.log_formatter
89 | config.logger = ActiveSupport::TaggedLogging.new(logger)
90 | end
91 |
92 | # Do not dump schema after migrations.
93 | config.active_record.dump_schema_after_migration = false
94 | end
95 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | require "active_support/core_ext/integer/time"
2 |
3 | # The test environment is used exclusively to run your application's
4 | # test suite. You never need to work with it otherwise. Remember that
5 | # your test database is "scratch space" for the test suite and is wiped
6 | # and recreated between test runs. Don't rely on the data there!
7 |
8 | Rails.application.configure do
9 | # Settings specified here will take precedence over those in config/application.rb.
10 |
11 | # Turn false under Spring and add config.action_view.cache_template_loading = true.
12 | config.cache_classes = true
13 |
14 | # Eager loading loads your whole application. When running a single test locally,
15 | # this probably isn't necessary. It's a good idea to do in a continuous integration
16 | # system, or in some way before deploying your code.
17 | config.eager_load = ENV["CI"].present?
18 |
19 | # Configure public file server for tests with Cache-Control for performance.
20 | config.public_file_server.enabled = true
21 | config.public_file_server.headers = {
22 | "Cache-Control" => "public, max-age=#{1.hour.to_i}"
23 | }
24 |
25 | # Show full error reports and disable caching.
26 | config.consider_all_requests_local = true
27 | config.action_controller.perform_caching = false
28 | config.cache_store = :null_store
29 |
30 | # Raise exceptions instead of rendering exception templates.
31 | config.action_dispatch.show_exceptions = false
32 |
33 | # Disable request forgery protection in test environment.
34 | config.action_controller.allow_forgery_protection = false
35 |
36 | # Store uploaded files on the local file system in a temporary directory.
37 | config.active_storage.service = :test
38 |
39 | config.action_mailer.perform_caching = false
40 |
41 | # Tell Action Mailer not to deliver emails to the real world.
42 | # The :test delivery method accumulates sent emails in the
43 | # ActionMailer::Base.deliveries array.
44 | config.action_mailer.delivery_method = :test
45 |
46 | # Print deprecation notices to the stderr.
47 | config.active_support.deprecation = :stderr
48 |
49 | # Raise exceptions for disallowed deprecations.
50 | config.active_support.disallowed_deprecation = :raise
51 |
52 | # Tell Active Support which deprecation messages to disallow.
53 | config.active_support.disallowed_deprecation_warnings = []
54 |
55 | # Raises error for missing translations.
56 | # config.i18n.raise_on_missing_translations = true
57 |
58 | # Annotate rendered view with file names.
59 | # config.action_view.annotate_rendered_view_with_filenames = true
60 | end
61 |
--------------------------------------------------------------------------------
/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = "1.0"
5 |
6 | # Add additional assets to the asset load path.
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 |
9 | Rails.application.config.assets.paths << Rails.root.join("node_modules")
10 | # Precompile additional assets.
11 | # application.js, application.css, and all non-JS/CSS in the app/assets
12 | # folder are already added.
13 | # Rails.application.config.assets.precompile += %w( admin.js admin.css )
14 |
15 | Rails.application.config.assets.paths << Rails.root.join("node_modules")
16 |
--------------------------------------------------------------------------------
/config/initializers/content_security_policy.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Define an application-wide content security policy.
4 | # See the Securing Rails Applications Guide for more information:
5 | # https://guides.rubyonrails.org/security.html#content-security-policy-header
6 |
7 | # Rails.application.configure do
8 | # config.content_security_policy do |policy|
9 | # policy.default_src :self, :https
10 | # policy.font_src :self, :https, :data
11 | # policy.img_src :self, :https, :data
12 | # policy.object_src :none
13 | # policy.script_src :self, :https
14 | # policy.style_src :self, :https
15 | # # Specify URI for violation reports
16 | # # policy.report_uri "/csp-violation-report-endpoint"
17 | # end
18 | #
19 | # # Generate session nonces for permitted importmap and inline scripts
20 | # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
21 | # config.content_security_policy_nonce_directives = %w(script-src)
22 | #
23 | # # Report violations without enforcing the policy.
24 | # # config.content_security_policy_report_only = true
25 | # end
26 |
--------------------------------------------------------------------------------
/config/initializers/default_meta.rb:
--------------------------------------------------------------------------------
1 | # config/initializers/default_meta.rb
2 |
3 | # Initialize default meta tags.
4 | DEFAULT_META = YAML.load_file(Rails.root.join("config/meta.yml"))
5 |
--------------------------------------------------------------------------------
/config/initializers/devise.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Assuming you have not yet modified this file, each configuration option below
4 | # is set to its default value. Note that some are commented out while others
5 | # are not: uncommented lines are intended to protect your configuration from
6 | # breaking changes in upgrades (i.e., in the event that future versions of
7 | # Devise change the default values for those options).
8 | #
9 | # Use this hook to configure devise mailer, warden hooks and so forth.
10 | # Many of these configuration options can be set straight in your model.
11 | Devise.setup do |config|
12 | # The secret key used by Devise. Devise uses this key to generate
13 | # random tokens. Changing this key will render invalid all existing
14 | # confirmation, reset password and unlock tokens in the database.
15 | # Devise will use the `secret_key_base` as its `secret_key`
16 | # by default. You can change it below and use your own secret key.
17 | # config.secret_key = '7e049113ea4a03562efead6e87ec8c1d5ff885394f7df86ee4e202456d5612968561dd5775bb05533ec1355c31134b7d30eb9fc7cf058e01b9e4439dcb560d56'
18 |
19 | # ==> Controller configuration
20 | # Configure the parent class to the devise controllers.
21 | # config.parent_controller = 'DeviseController'
22 |
23 | # ==> Mailer Configuration
24 | # Configure the e-mail address which will be shown in Devise::Mailer,
25 | # note that it will be overwritten if you use your own mailer class
26 | # with default "from" parameter.
27 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
28 |
29 | # Configure the class responsible to send e-mails.
30 | # config.mailer = 'Devise::Mailer'
31 |
32 | # Configure the parent class responsible to send e-mails.
33 | # config.parent_mailer = 'ActionMailer::Base'
34 |
35 | # ==> ORM configuration
36 | # Load and configure the ORM. Supports :active_record (default) and
37 | # :mongoid (bson_ext recommended) by default. Other ORMs may be
38 | # available as additional gems.
39 | require 'devise/orm/active_record'
40 |
41 | # ==> Configuration for any authentication mechanism
42 | # Configure which keys are used when authenticating a user. The default is
43 | # just :email. You can configure it to use [:username, :subdomain], so for
44 | # authenticating a user, both parameters are required. Remember that those
45 | # parameters are used only when authenticating and not when retrieving from
46 | # session. If you need permissions, you should implement that in a before filter.
47 | # You can also supply a hash where the value is a boolean determining whether
48 | # or not authentication should be aborted when the value is not present.
49 | # config.authentication_keys = [:email]
50 |
51 | # Configure parameters from the request object used for authentication. Each entry
52 | # given should be a request method and it will automatically be passed to the
53 | # find_for_authentication method and considered in your model lookup. For instance,
54 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
55 | # The same considerations mentioned for authentication_keys also apply to request_keys.
56 | # config.request_keys = []
57 |
58 | # Configure which authentication keys should be case-insensitive.
59 | # These keys will be downcased upon creating or modifying a user and when used
60 | # to authenticate or find a user. Default is :email.
61 | config.case_insensitive_keys = [:email]
62 |
63 | # Configure which authentication keys should have whitespace stripped.
64 | # These keys will have whitespace before and after removed upon creating or
65 | # modifying a user and when used to authenticate or find a user. Default is :email.
66 | config.strip_whitespace_keys = [:email]
67 |
68 | # Tell if authentication through request.params is enabled. True by default.
69 | # It can be set to an array that will enable params authentication only for the
70 | # given strategies, for example, `config.params_authenticatable = [:database]` will
71 | # enable it only for database (email + password) authentication.
72 | # config.params_authenticatable = true
73 |
74 | # Tell if authentication through HTTP Auth is enabled. False by default.
75 | # It can be set to an array that will enable http authentication only for the
76 | # given strategies, for example, `config.http_authenticatable = [:database]` will
77 | # enable it only for database authentication.
78 | # For API-only applications to support authentication "out-of-the-box", you will likely want to
79 | # enable this with :database unless you are using a custom strategy.
80 | # The supported strategies are:
81 | # :database = Support basic authentication with authentication key + password
82 | # config.http_authenticatable = false
83 |
84 | # If 401 status code should be returned for AJAX requests. True by default.
85 | # config.http_authenticatable_on_xhr = true
86 |
87 | # The realm used in Http Basic Authentication. 'Application' by default.
88 | # config.http_authentication_realm = 'Application'
89 |
90 | # It will change confirmation, password recovery and other workflows
91 | # to behave the same regardless if the e-mail provided was right or wrong.
92 | # Does not affect registerable.
93 | # config.paranoid = true
94 |
95 | # By default Devise will store the user in session. You can skip storage for
96 | # particular strategies by setting this option.
97 | # Notice that if you are skipping storage for all authentication paths, you
98 | # may want to disable generating routes to Devise's sessions controller by
99 | # passing skip: :sessions to `devise_for` in your config/routes.rb
100 | config.skip_session_storage = [:http_auth]
101 |
102 | # By default, Devise cleans up the CSRF token on authentication to
103 | # avoid CSRF token fixation attacks. This means that, when using AJAX
104 | # requests for sign in and sign up, you need to get a new CSRF token
105 | # from the server. You can disable this option at your own risk.
106 | # config.clean_up_csrf_token_on_authentication = true
107 |
108 | # When false, Devise will not attempt to reload routes on eager load.
109 | # This can reduce the time taken to boot the app but if your application
110 | # requires the Devise mappings to be loaded during boot time the application
111 | # won't boot properly.
112 | # config.reload_routes = true
113 |
114 | # ==> Configuration for :database_authenticatable
115 | # For bcrypt, this is the cost for hashing the password and defaults to 12. If
116 | # using other algorithms, it sets how many times you want the password to be hashed.
117 | # The number of stretches used for generating the hashed password are stored
118 | # with the hashed password. This allows you to change the stretches without
119 | # invalidating existing passwords.
120 | #
121 | # Limiting the stretches to just one in testing will increase the performance of
122 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
123 | # a value less than 10 in other environments. Note that, for bcrypt (the default
124 | # algorithm), the cost increases exponentially with the number of stretches (e.g.
125 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
126 | config.stretches = Rails.env.test? ? 1 : 12
127 |
128 | # Set up a pepper to generate the hashed password.
129 | # config.pepper = 'fd45cb3d6df3d29242ccbb8da1cd1e06bb4e93d2f1332f5ef8323c8499b9b7eade166ca276008ebd179b6b278aa2ecca7a51035be28d468d2f94bdd2b27ac9ec'
130 |
131 | # Send a notification to the original email when the user's email is changed.
132 | # config.send_email_changed_notification = false
133 |
134 | # Send a notification email when the user's password is changed.
135 | # config.send_password_change_notification = false
136 |
137 | # ==> Configuration for :confirmable
138 | # A period that the user is allowed to access the website even without
139 | # confirming their account. For instance, if set to 2.days, the user will be
140 | # able to access the website for two days without confirming their account,
141 | # access will be blocked just in the third day.
142 | # You can also set it to nil, which will allow the user to access the website
143 | # without confirming their account.
144 | # Default is 0.days, meaning the user cannot access the website without
145 | # confirming their account.
146 | # config.allow_unconfirmed_access_for = 2.days
147 |
148 | # A period that the user is allowed to confirm their account before their
149 | # token becomes invalid. For example, if set to 3.days, the user can confirm
150 | # their account within 3 days after the mail was sent, but on the fourth day
151 | # their account can't be confirmed with the token any more.
152 | # Default is nil, meaning there is no restriction on how long a user can take
153 | # before confirming their account.
154 | # config.confirm_within = 3.days
155 |
156 | # If true, requires any email changes to be confirmed (exactly the same way as
157 | # initial account confirmation) to be applied. Requires additional unconfirmed_email
158 | # db field (see migrations). Until confirmed, new email is stored in
159 | # unconfirmed_email column, and copied to email column on successful confirmation.
160 | config.reconfirmable = true
161 |
162 | # Defines which key will be used when confirming an account
163 | # config.confirmation_keys = [:email]
164 |
165 | # ==> Configuration for :rememberable
166 | # The time the user will be remembered without asking for credentials again.
167 | # config.remember_for = 2.weeks
168 |
169 | # Invalidates all the remember me tokens when the user signs out.
170 | config.expire_all_remember_me_on_sign_out = true
171 |
172 | # If true, extends the user's remember period when remembered via cookie.
173 | # config.extend_remember_period = false
174 |
175 | # Options to be passed to the created cookie. For instance, you can set
176 | # secure: true in order to force SSL only cookies.
177 | # config.rememberable_options = {}
178 |
179 | # ==> Configuration for :validatable
180 | # Range for password length.
181 | config.password_length = 6..128
182 |
183 | # Email regex used to validate email formats. It simply asserts that
184 | # one (and only one) @ exists in the given string. This is mainly
185 | # to give user feedback and not to assert the e-mail validity.
186 | config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
187 |
188 | # ==> Configuration for :timeoutable
189 | # The time you want to timeout the user session without activity. After this
190 | # time the user will be asked for credentials again. Default is 30 minutes.
191 | # config.timeout_in = 30.minutes
192 |
193 | # ==> Configuration for :lockable
194 | # Defines which strategy will be used to lock an account.
195 | # :failed_attempts = Locks an account after a number of failed attempts to sign in.
196 | # :none = No lock strategy. You should handle locking by yourself.
197 | # config.lock_strategy = :failed_attempts
198 |
199 | # Defines which key will be used when locking and unlocking an account
200 | # config.unlock_keys = [:email]
201 |
202 | # Defines which strategy will be used to unlock an account.
203 | # :email = Sends an unlock link to the user email
204 | # :time = Re-enables login after a certain amount of time (see :unlock_in below)
205 | # :both = Enables both strategies
206 | # :none = No unlock strategy. You should handle unlocking by yourself.
207 | # config.unlock_strategy = :both
208 |
209 | # Number of authentication tries before locking an account if lock_strategy
210 | # is failed attempts.
211 | # config.maximum_attempts = 20
212 |
213 | # Time interval to unlock the account if :time is enabled as unlock_strategy.
214 | # config.unlock_in = 1.hour
215 |
216 | # Warn on the last attempt before the account is locked.
217 | # config.last_attempt_warning = true
218 |
219 | # ==> Configuration for :recoverable
220 | #
221 | # Defines which key will be used when recovering the password for an account
222 | # config.reset_password_keys = [:email]
223 |
224 | # Time interval you can reset your password with a reset password key.
225 | # Don't put a too small interval or your users won't have the time to
226 | # change their passwords.
227 | config.reset_password_within = 6.hours
228 |
229 | # When set to false, does not sign a user in automatically after their password is
230 | # reset. Defaults to true, so a user is signed in automatically after a reset.
231 | # config.sign_in_after_reset_password = true
232 |
233 | # ==> Configuration for :encryptable
234 | # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
235 | # You can use :sha1, :sha512 or algorithms from others authentication tools as
236 | # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
237 | # for default behavior) and :restful_authentication_sha1 (then you should set
238 | # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
239 | #
240 | # Require the `devise-encryptable` gem when using anything other than bcrypt
241 | # config.encryptor = :sha512
242 |
243 | # ==> Scopes configuration
244 | # Turn scoped views on. Before rendering "sessions/new", it will first check for
245 | # "users/sessions/new". It's turned off by default because it's slower if you
246 | # are using only default views.
247 | # config.scoped_views = false
248 |
249 | # Configure the default scope given to Warden. By default it's the first
250 | # devise role declared in your routes (usually :user).
251 | # config.default_scope = :user
252 |
253 | # Set this configuration to false if you want /users/sign_out to sign out
254 | # only the current scope. By default, Devise signs out all scopes.
255 | # config.sign_out_all_scopes = true
256 |
257 | # ==> Navigation configuration
258 | # Lists the formats that should be treated as navigational. Formats like
259 | # :html, should redirect to the sign in page when the user does not have
260 | # access, but formats like :xml or :json, should return 401.
261 | #
262 | # If you have any extra navigational formats, like :iphone or :mobile, you
263 | # should add them to the navigational formats lists.
264 | #
265 | # The "*/*" below is required to match Internet Explorer requests.
266 | # config.navigational_formats = ['*/*', :html]
267 |
268 | # The default HTTP method used to sign out a resource. Default is :delete.
269 | config.sign_out_via = :delete
270 |
271 | # ==> OmniAuth
272 | # Add a new OmniAuth provider. Check the wiki for more information on setting
273 | # up on your models and hooks.
274 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
275 |
276 | # ==> Warden configuration
277 | # If you want to use other strategies, that are not supported by Devise, or
278 | # change the failure app, you can configure them inside the config.warden block.
279 | #
280 | # config.warden do |manager|
281 | # manager.intercept_401 = false
282 | # manager.default_strategies(scope: :user).unshift :some_external_strategy
283 | # end
284 |
285 | # ==> Mountable engine configurations
286 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine
287 | # is mountable, there are some extra configurations to be taken into account.
288 | # The following options are available, assuming the engine is mounted as:
289 | #
290 | # mount MyEngine, at: '/my_engine'
291 | #
292 | # The router that invoked `devise_for`, in the example above, would be:
293 | # config.router_name = :my_engine
294 | #
295 | # When using OmniAuth, Devise cannot automatically set OmniAuth path,
296 | # so you need to do it manually. For the users scope, it would be:
297 | # config.omniauth_path_prefix = '/my_engine/users/auth'
298 |
299 | # ==> Turbolinks configuration
300 | # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
301 | #
302 | # ActiveSupport.on_load(:devise_failure_app) do
303 | # include Turbolinks::Controller
304 | # end
305 |
306 | # ==> Configuration for :registerable
307 |
308 | # When set to false, does not sign a user in automatically after their password is
309 | # changed. Defaults to true, so a user is signed in automatically after changing a password.
310 | # config.sign_in_after_change_password = true
311 | end
312 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure parameters to be filtered from the log file. Use this to limit dissemination of
4 | # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
5 | # notations and behaviors.
6 | Rails.application.config.filter_parameters += [
7 | :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
8 | ]
9 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, "\\1en"
8 | # inflect.singular /^(ox)en/i, "\\1"
9 | # inflect.irregular "person", "people"
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym "RESTful"
16 | # end
17 |
--------------------------------------------------------------------------------
/config/initializers/permissions_policy.rb:
--------------------------------------------------------------------------------
1 | # Define an application-wide HTTP permissions policy. For further
2 | # information see https://developers.google.com/web/updates/2018/06/feature-policy
3 | #
4 | # Rails.application.config.permissions_policy do |f|
5 | # f.camera :none
6 | # f.gyroscope :none
7 | # f.microphone :none
8 | # f.usb :none
9 | # f.fullscreen :self
10 | # f.payment :self, "https://secure.example.com"
11 | # end
12 |
--------------------------------------------------------------------------------
/config/initializers/simple_form.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 | #
3 | # Uncomment this and change the path if necessary to include your own
4 | # components.
5 | # See https://github.com/heartcombo/simple_form#custom-components to know
6 | # more about custom components.
7 | # Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
8 | #
9 | # Use this setup block to configure all options available in SimpleForm.
10 | SimpleForm.setup do |config|
11 | # Wrappers are used by the form builder to generate a
12 | # complete input. You can remove any component from the
13 | # wrapper, change the order or even add your own to the
14 | # stack. The options given below are used to wrap the
15 | # whole input.
16 | config.wrappers :default, class: :input,
17 | hint_class: :field_with_hint, error_class: :field_with_errors, valid_class: :field_without_errors do |b|
18 | ## Extensions enabled by default
19 | # Any of these extensions can be disabled for a
20 | # given input by passing: `f.input EXTENSION_NAME => false`.
21 | # You can make any of these extensions optional by
22 | # renaming `b.use` to `b.optional`.
23 |
24 | # Determines whether to use HTML5 (:email, :url, ...)
25 | # and required attributes
26 | b.use :html5
27 |
28 | # Calculates placeholders automatically from I18n
29 | # You can also pass a string as f.input placeholder: "Placeholder"
30 | b.use :placeholder
31 |
32 | ## Optional extensions
33 | # They are disabled unless you pass `f.input EXTENSION_NAME => true`
34 | # to the input. If so, they will retrieve the values from the model
35 | # if any exists. If you want to enable any of those
36 | # extensions by default, you can change `b.optional` to `b.use`.
37 |
38 | # Calculates maxlength from length validations for string inputs
39 | # and/or database column lengths
40 | b.optional :maxlength
41 |
42 | # Calculate minlength from length validations for string inputs
43 | b.optional :minlength
44 |
45 | # Calculates pattern from format validations for string inputs
46 | b.optional :pattern
47 |
48 | # Calculates min and max from length validations for numeric inputs
49 | b.optional :min_max
50 |
51 | # Calculates readonly automatically from readonly attributes
52 | b.optional :readonly
53 |
54 | ## Inputs
55 | # b.use :input, class: 'input', error_class: 'is-invalid', valid_class: 'is-valid'
56 | b.use :label_input
57 | b.use :hint, wrap_with: { tag: :span, class: :hint }
58 | b.use :error, wrap_with: { tag: :span, class: :error }
59 |
60 | ## full_messages_for
61 | # If you want to display the full error message for the attribute, you can
62 | # use the component :full_error, like:
63 | #
64 | # b.use :full_error, wrap_with: { tag: :span, class: :error }
65 | end
66 |
67 | # The default wrapper to be used by the FormBuilder.
68 | config.default_wrapper = :default
69 |
70 | # Define the way to render check boxes / radio buttons with labels.
71 | # Defaults to :nested for bootstrap config.
72 | # inline: input + label
73 | # nested: label > input
74 | config.boolean_style = :nested
75 |
76 | # Default class for buttons
77 | config.button_class = 'btn'
78 |
79 | # Method used to tidy up errors. Specify any Rails Array method.
80 | # :first lists the first message for each field.
81 | # Use :to_sentence to list all errors for each field.
82 | # config.error_method = :first
83 |
84 | # Default tag used for error notification helper.
85 | config.error_notification_tag = :div
86 |
87 | # CSS class to add for error notification helper.
88 | config.error_notification_class = 'error_notification'
89 |
90 | # Series of attempts to detect a default label method for collection.
91 | # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
92 |
93 | # Series of attempts to detect a default value method for collection.
94 | # config.collection_value_methods = [ :id, :to_s ]
95 |
96 | # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
97 | # config.collection_wrapper_tag = nil
98 |
99 | # You can define the class to use on all collection wrappers. Defaulting to none.
100 | # config.collection_wrapper_class = nil
101 |
102 | # You can wrap each item in a collection of radio/check boxes with a tag,
103 | # defaulting to :span.
104 | # config.item_wrapper_tag = :span
105 |
106 | # You can define a class to use in all item wrappers. Defaulting to none.
107 | # config.item_wrapper_class = nil
108 |
109 | # How the label text should be generated altogether with the required text.
110 | # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
111 |
112 | # You can define the class to use on all labels. Default is nil.
113 | # config.label_class = nil
114 |
115 | # You can define the default class to be used on forms. Can be overridden
116 | # with `html: { :class }`. Defaulting to none.
117 | # config.default_form_class = nil
118 |
119 | # You can define which elements should obtain additional classes
120 | # config.generate_additional_classes_for = [:wrapper, :label, :input]
121 |
122 | # Whether attributes are required by default (or not). Default is true.
123 | # config.required_by_default = true
124 |
125 | # Tell browsers whether to use the native HTML5 validations (novalidate form option).
126 | # These validations are enabled in SimpleForm's internal config but disabled by default
127 | # in this configuration, which is recommended due to some quirks from different browsers.
128 | # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
129 | # change this configuration to true.
130 | config.browser_validations = false
131 |
132 | # Custom mappings for input types. This should be a hash containing a regexp
133 | # to match as key, and the input type that will be used when the field name
134 | # matches the regexp as value.
135 | # config.input_mappings = { /count/ => :integer }
136 |
137 | # Custom wrappers for input types. This should be a hash containing an input
138 | # type as key and the wrapper that will be used for all inputs with specified type.
139 | # config.wrapper_mappings = { string: :prepend }
140 |
141 | # Namespaces where SimpleForm should look for custom input classes that
142 | # override default inputs.
143 | # config.custom_inputs_namespaces << "CustomInputs"
144 |
145 | # Default priority for time_zone inputs.
146 | # config.time_zone_priority = nil
147 |
148 | # Default priority for country inputs.
149 | # config.country_priority = nil
150 |
151 | # When false, do not use translations for labels.
152 | # config.translate_labels = true
153 |
154 | # Automatically discover new inputs in Rails' autoload path.
155 | # config.inputs_discovery = true
156 |
157 | # Cache SimpleForm inputs discovery
158 | # config.cache_discovery = !Rails.env.development?
159 |
160 | # Default class for inputs
161 | # config.input_class = nil
162 |
163 | # Define the default class of the input wrapper of the boolean input.
164 | config.boolean_label_class = 'checkbox'
165 |
166 | # Defines if the default input wrapper class should be included in radio
167 | # collection wrappers.
168 | # config.include_default_input_wrapper_class = true
169 |
170 | # Defines which i18n scope will be used in Simple Form.
171 | # config.i18n_scope = 'simple_form'
172 |
173 | # Defines validation classes to the input_field. By default it's nil.
174 | # config.input_field_valid_class = 'is-valid'
175 | # config.input_field_error_class = 'is-invalid'
176 | end
177 |
--------------------------------------------------------------------------------
/config/initializers/simple_form_bootstrap.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # These defaults are defined and maintained by the community at
4 | # https://github.com/heartcombo/simple_form-bootstrap
5 | # Please submit feedback, changes and tests only there.
6 |
7 | # Uncomment this and change the path if necessary to include your own
8 | # components.
9 | # See https://github.com/heartcombo/simple_form#custom-components
10 | # to know more about custom components.
11 | # Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
12 |
13 | # Use this setup block to configure all options available in SimpleForm.
14 | SimpleForm.setup do |config|
15 | # Default class for buttons
16 | config.button_class = 'btn'
17 |
18 | # Define the default class of the input wrapper of the boolean input.
19 | config.boolean_label_class = 'form-check-label'
20 |
21 | # How the label text should be generated altogether with the required text.
22 | config.label_text = lambda { |label, required, explicit_label| "#{label} #{required}" }
23 |
24 | # Define the way to render check boxes / radio buttons with labels.
25 | config.boolean_style = :inline
26 |
27 | # You can wrap each item in a collection of radio/check boxes with a tag
28 | config.item_wrapper_tag = :div
29 |
30 | # Defines if the default input wrapper class should be included in radio
31 | # collection wrappers.
32 | config.include_default_input_wrapper_class = false
33 |
34 | # CSS class to add for error notification helper.
35 | config.error_notification_class = 'alert alert-danger'
36 |
37 | # Method used to tidy up errors. Specify any Rails Array method.
38 | # :first lists the first message for each field.
39 | # :to_sentence to list all errors for each field.
40 | config.error_method = :to_sentence
41 |
42 | # add validation classes to `input_field`
43 | config.input_field_error_class = 'is-invalid'
44 | config.input_field_valid_class = 'is-valid'
45 |
46 |
47 | # vertical forms
48 | #
49 | # vertical default_wrapper
50 | config.wrappers :vertical_form, class: 'mb-3' do |b|
51 | b.use :html5
52 | b.use :placeholder
53 | b.optional :maxlength
54 | b.optional :minlength
55 | b.optional :pattern
56 | b.optional :min_max
57 | b.optional :readonly
58 | b.use :label, class: 'form-label'
59 | b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
60 | b.use :full_error, wrap_with: { class: 'invalid-feedback' }
61 | b.use :hint, wrap_with: { class: 'form-text' }
62 | end
63 |
64 | # vertical input for boolean
65 | config.wrappers :vertical_boolean, tag: 'fieldset', class: 'mb-3' do |b|
66 | b.use :html5
67 | b.optional :readonly
68 | b.wrapper :form_check_wrapper, class: 'form-check' do |bb|
69 | bb.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
70 | bb.use :label, class: 'form-check-label'
71 | bb.use :full_error, wrap_with: { class: 'invalid-feedback' }
72 | bb.use :hint, wrap_with: { class: 'form-text' }
73 | end
74 | end
75 |
76 | # vertical input for radio buttons and check boxes
77 | config.wrappers :vertical_collection, item_wrapper_class: 'form-check form-check-question', item_label_class: 'form-check-label form-check-label-question', tag: 'fieldset', class: 'mb-3' do |b|
78 | b.use :html5
79 | b.optional :readonly
80 | b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
81 | ba.use :label_text
82 | end
83 | b.use :input, class: 'form-check-input form-check-input-question', error_class: 'is-invalid', valid_class: 'is-valid'
84 | b.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
85 | b.use :hint, wrap_with: { class: 'form-text' }
86 | end
87 |
88 | # vertical input for inline radio buttons and check boxes
89 | config.wrappers :vertical_collection_inline, item_wrapper_class: 'form-check form-check-question form-check-inline', item_label_class: 'form-check-label form-check-label-question', tag: 'fieldset', class: 'mb-3' do |b|
90 | b.use :html5
91 | b.optional :readonly
92 | b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
93 | ba.use :label_text
94 | end
95 | b.use :input, class: 'form-check-input form-check-input-question', error_class: 'is-invalid', valid_class: 'is-valid'
96 | b.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
97 | b.use :hint, wrap_with: { class: 'form-text' }
98 | end
99 |
100 | # vertical file input
101 | config.wrappers :vertical_file, class: 'mb-3' do |b|
102 | b.use :html5
103 | b.use :placeholder
104 | b.optional :maxlength
105 | b.optional :minlength
106 | b.optional :readonly
107 | b.use :label, class: 'form-label'
108 | b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
109 | b.use :full_error, wrap_with: { class: 'invalid-feedback' }
110 | b.use :hint, wrap_with: { class: 'form-text' }
111 | end
112 |
113 | # vertical select input
114 | config.wrappers :vertical_select, class: 'mb-3' do |b|
115 | b.use :html5
116 | b.optional :readonly
117 | b.use :label, class: 'form-label'
118 | b.use :input, class: 'form-select', error_class: 'is-invalid', valid_class: 'is-valid'
119 | b.use :full_error, wrap_with: { class: 'invalid-feedback' }
120 | b.use :hint, wrap_with: { class: 'form-text' }
121 | end
122 |
123 | # vertical multi select
124 | config.wrappers :vertical_multi_select, class: 'mb-3' do |b|
125 | b.use :html5
126 | b.optional :readonly
127 | b.use :label, class: 'form-label'
128 | b.wrapper class: 'd-flex flex-row justify-content-between align-items-center' do |ba|
129 | ba.use :input, class: 'form-select mx-1', error_class: 'is-invalid', valid_class: 'is-valid'
130 | end
131 | b.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
132 | b.use :hint, wrap_with: { class: 'form-text' }
133 | end
134 |
135 | # vertical range input
136 | config.wrappers :vertical_range, class: 'mb-3' do |b|
137 | b.use :html5
138 | b.use :placeholder
139 | b.optional :readonly
140 | b.optional :step
141 | b.use :label, class: 'form-label'
142 | b.use :input, class: 'form-range', error_class: 'is-invalid', valid_class: 'is-valid'
143 | b.use :full_error, wrap_with: { class: 'invalid-feedback' }
144 | b.use :hint, wrap_with: { class: 'form-text' }
145 | end
146 |
147 |
148 | # horizontal forms
149 | #
150 | # horizontal default_wrapper
151 | config.wrappers :horizontal_form, class: 'row mb-3' do |b|
152 | b.use :html5
153 | b.use :placeholder
154 | b.optional :maxlength
155 | b.optional :minlength
156 | b.optional :pattern
157 | b.optional :min_max
158 | b.optional :readonly
159 | b.use :label, class: 'col-sm-3 col-form-label'
160 | b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
161 | ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
162 | ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
163 | ba.use :hint, wrap_with: { class: 'form-text' }
164 | end
165 | end
166 |
167 | # horizontal input for boolean
168 | config.wrappers :horizontal_boolean, class: 'row mb-3' do |b|
169 | b.use :html5
170 | b.optional :readonly
171 | b.wrapper :grid_wrapper, class: 'col-sm-9 offset-sm-3' do |wr|
172 | wr.wrapper :form_check_wrapper, class: 'form-check' do |bb|
173 | bb.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
174 | bb.use :label, class: 'form-check-label'
175 | bb.use :full_error, wrap_with: { class: 'invalid-feedback' }
176 | bb.use :hint, wrap_with: { class: 'form-text' }
177 | end
178 | end
179 | end
180 |
181 | # horizontal input for radio buttons and check boxes
182 | config.wrappers :horizontal_collection, item_wrapper_class: 'form-check form-check-question', item_label_class: 'form-check-label form-check-label-question', class: 'row mb-3' do |b|
183 | b.use :html5
184 | b.optional :readonly
185 | b.use :label, class: 'col-sm-3 col-form-label pt-0'
186 | b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
187 | ba.use :input, class: 'form-check-input form-check-input-question', error_class: 'is-invalid', valid_class: 'is-valid'
188 | ba.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
189 | ba.use :hint, wrap_with: { class: 'form-text' }
190 | end
191 | end
192 |
193 | # horizontal input for inline radio buttons and check boxes
194 | config.wrappers :horizontal_collection_inline, item_wrapper_class: 'form-check form-check-inline', item_label_class: 'form-check-label', class: 'row mb-3' do |b|
195 | b.use :html5
196 | b.optional :readonly
197 | b.use :label, class: 'col-sm-3 col-form-label pt-0'
198 | b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
199 | ba.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
200 | ba.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
201 | ba.use :hint, wrap_with: { class: 'form-text' }
202 | end
203 | end
204 |
205 | # horizontal file input
206 | config.wrappers :horizontal_file, class: 'row mb-3' do |b|
207 | b.use :html5
208 | b.use :placeholder
209 | b.optional :maxlength
210 | b.optional :minlength
211 | b.optional :readonly
212 | b.use :label, class: 'col-sm-3 col-form-label'
213 | b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
214 | ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
215 | ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
216 | ba.use :hint, wrap_with: { class: 'form-text' }
217 | end
218 | end
219 |
220 | # horizontal select input
221 | config.wrappers :horizontal_select, class: 'row mb-3' do |b|
222 | b.use :html5
223 | b.optional :readonly
224 | b.use :label, class: 'col-sm-3 col-form-label'
225 | b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
226 | ba.use :input, class: 'form-select', error_class: 'is-invalid', valid_class: 'is-valid'
227 | ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
228 | ba.use :hint, wrap_with: { class: 'form-text' }
229 | end
230 | end
231 |
232 | # horizontal multi select
233 | config.wrappers :horizontal_multi_select, class: 'row mb-3' do |b|
234 | b.use :html5
235 | b.optional :readonly
236 | b.use :label, class: 'col-sm-3 col-form-label'
237 | b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
238 | ba.wrapper class: 'd-flex flex-row justify-content-between align-items-center' do |bb|
239 | bb.use :input, class: 'form-select mx-1', error_class: 'is-invalid', valid_class: 'is-valid'
240 | end
241 | ba.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
242 | ba.use :hint, wrap_with: { class: 'form-text' }
243 | end
244 | end
245 |
246 | # horizontal range input
247 | config.wrappers :horizontal_range, class: 'row mb-3' do |b|
248 | b.use :html5
249 | b.use :placeholder
250 | b.optional :readonly
251 | b.optional :step
252 | b.use :label, class: 'col-sm-3 col-form-label pt-0'
253 | b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
254 | ba.use :input, class: 'form-range', error_class: 'is-invalid', valid_class: 'is-valid'
255 | ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
256 | ba.use :hint, wrap_with: { class: 'form-text' }
257 | end
258 | end
259 |
260 |
261 | # inline forms
262 | #
263 | # inline default_wrapper
264 | config.wrappers :inline_form, class: 'col-12' do |b|
265 | b.use :html5
266 | b.use :placeholder
267 | b.optional :maxlength
268 | b.optional :minlength
269 | b.optional :pattern
270 | b.optional :min_max
271 | b.optional :readonly
272 | b.use :label, class: 'visually-hidden'
273 |
274 | b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
275 | b.use :error, wrap_with: { class: 'invalid-feedback' }
276 | b.optional :hint, wrap_with: { class: 'form-text' }
277 | end
278 |
279 | # inline input for boolean
280 | config.wrappers :inline_boolean, class: 'col-12' do |b|
281 | b.use :html5
282 | b.optional :readonly
283 | b.wrapper :form_check_wrapper, class: 'form-check' do |bb|
284 | bb.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
285 | bb.use :label, class: 'form-check-label'
286 | bb.use :error, wrap_with: { class: 'invalid-feedback' }
287 | bb.optional :hint, wrap_with: { class: 'form-text' }
288 | end
289 | end
290 |
291 |
292 | # bootstrap custom forms
293 | #
294 | # custom input switch for boolean
295 | config.wrappers :custom_boolean_switch, class: 'mb-3' do |b|
296 | b.use :html5
297 | b.optional :readonly
298 | b.wrapper :form_check_wrapper, tag: 'div', class: 'form-check form-switch' do |bb|
299 | bb.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
300 | bb.use :label, class: 'form-check-label'
301 | bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
302 | bb.use :hint, wrap_with: { class: 'form-text' }
303 | end
304 | end
305 |
306 |
307 | # Input Group - custom component
308 | # see example app and config at https://github.com/heartcombo/simple_form-bootstrap
309 | config.wrappers :input_group, class: 'mb-3' do |b|
310 | b.use :html5
311 | b.use :placeholder
312 | b.optional :maxlength
313 | b.optional :minlength
314 | b.optional :pattern
315 | b.optional :min_max
316 | b.optional :readonly
317 | b.use :label, class: 'form-label'
318 | b.wrapper :input_group_tag, class: 'input-group' do |ba|
319 | ba.optional :prepend
320 | ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
321 | ba.optional :append
322 | ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
323 | end
324 | b.use :hint, wrap_with: { class: 'form-text' }
325 | end
326 |
327 |
328 | # Floating Labels form
329 | #
330 | # floating labels default_wrapper
331 | config.wrappers :floating_labels_form, class: 'form-floating mb-3' do |b|
332 | b.use :html5
333 | b.use :placeholder
334 | b.optional :maxlength
335 | b.optional :minlength
336 | b.optional :pattern
337 | b.optional :min_max
338 | b.optional :readonly
339 | b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
340 | b.use :label
341 | b.use :full_error, wrap_with: { class: 'invalid-feedback' }
342 | b.use :hint, wrap_with: { class: 'form-text' }
343 | end
344 |
345 | # custom multi select
346 | config.wrappers :floating_labels_select, class: 'form-floating mb-3' do |b|
347 | b.use :html5
348 | b.optional :readonly
349 | b.use :input, class: 'form-select', error_class: 'is-invalid', valid_class: 'is-valid'
350 | b.use :label
351 | b.use :full_error, wrap_with: { class: 'invalid-feedback' }
352 | b.use :hint, wrap_with: { class: 'form-text' }
353 | end
354 |
355 |
356 | # The default wrapper to be used by the FormBuilder.
357 | config.default_wrapper = :vertical_form
358 |
359 | # Custom wrappers for input types. This should be a hash containing an input
360 | # type as key and the wrapper that will be used for all inputs with specified type.
361 | config.wrapper_mappings = {
362 | boolean: :vertical_boolean,
363 | check_boxes: :vertical_collection,
364 | date: :vertical_multi_select,
365 | datetime: :vertical_multi_select,
366 | file: :vertical_file,
367 | radio_buttons: :vertical_collection,
368 | range: :vertical_range,
369 | time: :vertical_multi_select,
370 | select: :vertical_select
371 | }
372 | end
373 |
--------------------------------------------------------------------------------
/config/locales/devise.en.yml:
--------------------------------------------------------------------------------
1 | # Additional translations at https://github.com/heartcombo/devise/wiki/I18n
2 |
3 | en:
4 | devise:
5 | confirmations:
6 | confirmed: "Your email address has been successfully confirmed."
7 | send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8 | send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
9 | failure:
10 | already_authenticated: "You are already signed in."
11 | inactive: "Your account is not activated yet."
12 | invalid: "Invalid %{authentication_keys} or password."
13 | locked: "Your account is locked."
14 | last_attempt: "You have one more attempt before your account is locked."
15 | not_found_in_database: "Invalid %{authentication_keys} or password."
16 | timeout: "Your session expired. Please sign in again to continue."
17 | unauthenticated: "You need to sign in or sign up before continuing."
18 | unconfirmed: "You have to confirm your email address before continuing."
19 | mailer:
20 | confirmation_instructions:
21 | subject: "Confirmation instructions"
22 | reset_password_instructions:
23 | subject: "Reset password instructions"
24 | unlock_instructions:
25 | subject: "Unlock instructions"
26 | email_changed:
27 | subject: "Email Changed"
28 | password_change:
29 | subject: "Password Changed"
30 | omniauth_callbacks:
31 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
32 | success: "Successfully authenticated from %{kind} account."
33 | passwords:
34 | no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
35 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
36 | send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
37 | updated: "Your password has been changed successfully. You are now signed in."
38 | updated_not_active: "Your password has been changed successfully."
39 | registrations:
40 | destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
41 | signed_up: "Welcome! You have signed up successfully."
42 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
43 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
44 | signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
45 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
46 | updated: "Your account has been updated successfully."
47 | updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again."
48 | sessions:
49 | signed_in: "Signed in successfully."
50 | signed_out: "Signed out successfully."
51 | already_signed_out: "Signed out successfully."
52 | unlocks:
53 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
54 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
55 | unlocked: "Your account has been unlocked successfully. Please sign in to continue."
56 | errors:
57 | messages:
58 | already_confirmed: "was already confirmed, please try signing in"
59 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
60 | expired: "has expired, please request a new one"
61 | not_found: "not found"
62 | not_locked: "was not locked"
63 | not_saved:
64 | one: "1 error prohibited this %{resource} from being saved:"
65 | other: "%{count} errors prohibited this %{resource} from being saved:"
66 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t "hello"
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t("hello") %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # The following keys must be escaped otherwise they will not be retrieved by
20 | # the default I18n backend:
21 | #
22 | # true, false, on, off, yes, no
23 | #
24 | # Instead, surround them with single quotes.
25 | #
26 | # en:
27 | # "true": "foo"
28 | #
29 | # To learn more, please read the Rails Internationalization guide
30 | # available at https://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 |
--------------------------------------------------------------------------------
/config/locales/simple_form.en.yml:
--------------------------------------------------------------------------------
1 | en:
2 | simple_form:
3 | "yes": 'Yes'
4 | "no": 'No'
5 | required:
6 | text: 'required'
7 | mark: '*'
8 | # You can uncomment the line below if you need to overwrite the whole required html.
9 | # When using html, text and mark won't be used.
10 | # html: '*'
11 | error_notification:
12 | default_message: "Please review the problems below:"
13 | # Examples
14 | # labels:
15 | # defaults:
16 | # password: 'Password'
17 | # user:
18 | # new:
19 | # email: 'E-mail to sign in.'
20 | # edit:
21 | # email: 'E-mail.'
22 | # hints:
23 | # defaults:
24 | # username: 'User name to sign in.'
25 | # password: 'No special characters, please.'
26 | # include_blanks:
27 | # defaults:
28 | # age: 'Rather not say'
29 | # prompts:
30 | # defaults:
31 | # age: 'Select your age'
32 |
--------------------------------------------------------------------------------
/config/meta.yml:
--------------------------------------------------------------------------------
1 | meta_product_name: "Elect"
2 | meta_title: "Elect - Who will represent me?"
3 | meta_description: "This app is here to help you identify who are the best candidates to represent your political beliefs!"
4 | meta_image: "background-elect.png" # should exist in `app/assets/images/`
5 | twitter_account: "@product_twitter_account" # required for Twitter Cards
6 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | # Puma can serve each request in a thread from an internal thread pool.
2 | # The `threads` method setting takes two numbers: a minimum and maximum.
3 | # Any libraries that use thread pools should be configured to match
4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum
5 | # and maximum; this matches the default thread size of Active Record.
6 | #
7 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
9 | threads min_threads_count, max_threads_count
10 |
11 | # Specifies the `worker_timeout` threshold that Puma will use to wait before
12 | # terminating a worker in development environments.
13 | #
14 | worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
15 |
16 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
17 | #
18 | port ENV.fetch("PORT") { 3000 }
19 |
20 | # Specifies the `environment` that Puma will run in.
21 | #
22 | environment ENV.fetch("RAILS_ENV") { "development" }
23 |
24 | # Specifies the `pidfile` that Puma will use.
25 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
26 |
27 | # Specifies the number of `workers` to boot in clustered mode.
28 | # Workers are forked web server processes. If using threads and workers together
29 | # the concurrency of the application would be max `threads` * `workers`.
30 | # Workers do not work on JRuby or Windows (both of which do not support
31 | # processes).
32 | #
33 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
34 |
35 | # Use the `preload_app!` method when specifying a `workers` number.
36 | # This directive tells Puma to first boot the application and load code
37 | # before forking the application. This takes advantage of Copy On Write
38 | # process behavior so workers use less memory.
39 | #
40 | # preload_app!
41 |
42 | # Allow puma to be restarted by `bin/rails restart` command.
43 | plugin :tmp_restart
44 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | devise_for :users
3 | root to: "pages#home"
4 |
5 | get "devise/users", to: "users#show"
6 | resources :questions
7 | resources :user_answers
8 | resources :searches
9 | resources :abouts
10 |
11 | # patch 'questions', to: 'questions#profile_definition'
12 |
13 | resources :users do
14 | collection do
15 | get :top
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/config/storage.yml:
--------------------------------------------------------------------------------
1 | test:
2 | service: Disk
3 | root: <%= Rails.root.join("tmp/storage") %>
4 |
5 | local:
6 | service: Disk
7 | root: <%= Rails.root.join("storage") %>
8 |
9 | cloudinary:
10 | service: Cloudinary
11 | folder: <%= Rails.env %>
12 |
13 | # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
14 | # amazon:
15 | # service: S3
16 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
17 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
18 | # region: us-east-1
19 | # bucket: your_own_bucket-<%= Rails.env %>
20 |
21 | # Remember not to checkin your GCS keyfile to a repository
22 | # google:
23 | # service: GCS
24 | # project: your_project
25 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
26 | # bucket: your_own_bucket-<%= Rails.env %>
27 |
28 | # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
29 | # microsoft:
30 | # service: AzureStorage
31 | # storage_account_name: your_account_name
32 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
33 | # container: your_container_name-<%= Rails.env %>
34 |
35 | # mirror:
36 | # service: Mirror
37 | # primary: local
38 | # mirrors: [ amazon, google, microsoft ]
39 |
--------------------------------------------------------------------------------
/db/data/answers.csv:
--------------------------------------------------------------------------------
1 | 'content','profile'
2 | 'Agree','right'
3 | 'I'm Neutral','center'
4 | 'Disagree','left'
5 |
--------------------------------------------------------------------------------
/db/data/questions.csv:
--------------------------------------------------------------------------------
1 | content,photo
2 | 1. Racial quotas in universities and contests is a good solution to correct the mistakes that Brazil made in the past against this part of the population.,Question-1.jpg
3 | 2. The defense of Human Rights is fundamental to combat injustices in the society.,Question-2.jpg
4 | 3. The government should promote economic growth using public resources to help companies grow.,Question-3.jpg
5 | 4. The Brazilian government has an obligation to pay permanent cash assistance to the poorest.,Question-4.jpg
6 | 5. It is important to discuss the liberalization of some drugs as an alternative to fight the crime.,Question-5.jpg
7 | 6. The non-violent prisoners should be released from prison to reduce overcrowding.,Question-6.jpg
8 | 7. Religion should not interfere in state decisions.,Question-7.jpg
9 | 8. Abortion is not a matter of ideology but of public health.,Question-8.jpg
10 | 9. Pensions for family members of the armed forces must be reviewed so that there is money left for the Federal Government.,Question-9.jpg
11 | 10. Marriage should always be between people who love each other regardless of gender.,Question-10.jpg
12 |
--------------------------------------------------------------------------------
/db/migrate/20221129182412_devise_create_users.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class DeviseCreateUsers < ActiveRecord::Migration[7.0]
4 | def change
5 | create_table :users do |t|
6 | ## Database authenticatable
7 | t.string :email, null: false, default: ""
8 | t.string :encrypted_password, null: false, default: ""
9 |
10 | ## Recoverable
11 | t.string :reset_password_token
12 | t.datetime :reset_password_sent_at
13 |
14 | ## Rememberable
15 | t.datetime :remember_created_at
16 |
17 | ## Trackable
18 | # t.integer :sign_in_count, default: 0, null: false
19 | # t.datetime :current_sign_in_at
20 | # t.datetime :last_sign_in_at
21 | # t.string :current_sign_in_ip
22 | # t.string :last_sign_in_ip
23 |
24 | ## Confirmable
25 | # t.string :confirmation_token
26 | # t.datetime :confirmed_at
27 | # t.datetime :confirmation_sent_at
28 | # t.string :unconfirmed_email # Only if using reconfirmable
29 |
30 | ## Lockable
31 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
32 | # t.string :unlock_token # Only if unlock strategy is :email or :both
33 | # t.datetime :locked_at
34 |
35 |
36 | t.timestamps null: false
37 | end
38 |
39 | add_index :users, :email, unique: true
40 | add_index :users, :reset_password_token, unique: true
41 | # add_index :users, :confirmation_token, unique: true
42 | # add_index :users, :unlock_token, unique: true
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/db/migrate/20221129184113_create_questions.rb:
--------------------------------------------------------------------------------
1 | class CreateQuestions < ActiveRecord::Migration[7.0]
2 | def change
3 | create_table :questions do |t|
4 | t.string :content
5 | t.string :photo
6 | t.timestamps
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20221129184123_create_answers.rb:
--------------------------------------------------------------------------------
1 | class CreateAnswers < ActiveRecord::Migration[7.0]
2 | def change
3 | create_table :answers do |t|
4 | t.references :question, null: false, foreign_key: true
5 | t.string :content
6 | t.string :profile
7 | t.timestamps
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20221129184131_create_user_answers.rb:
--------------------------------------------------------------------------------
1 | class CreateUserAnswers < ActiveRecord::Migration[7.0]
2 | def change
3 | create_table :user_answers do |t|
4 | t.references :user, null: false, foreign_key: true
5 | t.references :answer, null: false, foreign_key: true
6 | t.integer :weight
7 | t.timestamps
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20221129191406_add_columns_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddColumnsToUsers < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :users, :name, :string
4 | add_column :users, :role, :string
5 | add_column :users, :state, :string
6 | add_column :users, :party, :string
7 | add_column :users, :race, :string
8 | add_column :users, :gender, :string
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20221130222019_create_active_storage_tables.active_storage.rb:
--------------------------------------------------------------------------------
1 | # This migration comes from active_storage (originally 20170806125915)
2 | class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
3 | def change
4 | # Use Active Record's configured type for primary and foreign keys
5 | primary_key_type, foreign_key_type = primary_and_foreign_key_types
6 |
7 | create_table :active_storage_blobs, id: primary_key_type do |t|
8 | t.string :key, null: false
9 | t.string :filename, null: false
10 | t.string :content_type
11 | t.text :metadata
12 | t.string :service_name, null: false
13 | t.bigint :byte_size, null: false
14 | t.string :checksum
15 |
16 | if connection.supports_datetime_with_precision?
17 | t.datetime :created_at, precision: 6, null: false
18 | else
19 | t.datetime :created_at, null: false
20 | end
21 |
22 | t.index [ :key ], unique: true
23 | end
24 |
25 | create_table :active_storage_attachments, id: primary_key_type do |t|
26 | t.string :name, null: false
27 | t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
28 | t.references :blob, null: false, type: foreign_key_type
29 |
30 | if connection.supports_datetime_with_precision?
31 | t.datetime :created_at, precision: 6, null: false
32 | else
33 | t.datetime :created_at, null: false
34 | end
35 |
36 | t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true
37 | t.foreign_key :active_storage_blobs, column: :blob_id
38 | end
39 |
40 | create_table :active_storage_variant_records, id: primary_key_type do |t|
41 | t.belongs_to :blob, null: false, index: false, type: foreign_key_type
42 | t.string :variation_digest, null: false
43 |
44 | t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true
45 | t.foreign_key :active_storage_blobs, column: :blob_id
46 | end
47 | end
48 |
49 | private
50 | def primary_and_foreign_key_types
51 | config = Rails.configuration.generators
52 | setting = config.options[config.orm][:primary_key_type]
53 | primary_key_type = setting || :primary_key
54 | foreign_key_type = setting || :bigint
55 | [primary_key_type, foreign_key_type]
56 | end
57 | end
58 |
--------------------------------------------------------------------------------
/db/migrate/20221201182643_create_searches.rb:
--------------------------------------------------------------------------------
1 | class CreateSearches < ActiveRecord::Migration[7.0]
2 | def change
3 | create_table :searches do |t|
4 | t.string :state
5 | t.string :party
6 | t.string :gender
7 | t.string :race
8 |
9 | t.timestamps
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/db/migrate/20221201193312_add_columns_to_searches.rb:
--------------------------------------------------------------------------------
1 | class AddColumnsToSearches < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :searches, :name, :string
4 | add_column :searches, :role, :string
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/db/migrate/20221205165541_create_abouts.rb:
--------------------------------------------------------------------------------
1 | class CreateAbouts < ActiveRecord::Migration[7.0]
2 | def change
3 | create_table :abouts do |t|
4 | t.string :title
5 | t.string :content
6 |
7 | t.timestamps
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20221205165810_add_orientation_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddOrientationToUsers < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :users, :orientation, :string, default: ''
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # This file is auto-generated from the current state of the database. Instead
2 | # of editing this file, please use the migrations feature of Active Record to
3 | # incrementally modify your database, and then regenerate this schema definition.
4 | #
5 | # This file is the source Rails uses to define your schema when running `bin/rails
6 | # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7 | # be faster and is potentially less error prone than running all of your
8 | # migrations from scratch. Old migrations may fail to apply correctly if those
9 | # migrations use external dependencies or application code.
10 | #
11 | # It's strongly recommended that you check this file into your version control system.
12 |
13 | ActiveRecord::Schema[7.0].define(version: 2022_12_05_165810) do
14 | # These are extensions that must be enabled in order to support this database
15 | enable_extension "plpgsql"
16 |
17 | create_table "abouts", force: :cascade do |t|
18 | t.string "title"
19 | t.string "content"
20 | t.datetime "created_at", null: false
21 | t.datetime "updated_at", null: false
22 | end
23 |
24 | create_table "active_storage_attachments", force: :cascade do |t|
25 | t.string "name", null: false
26 | t.string "record_type", null: false
27 | t.bigint "record_id", null: false
28 | t.bigint "blob_id", null: false
29 | t.datetime "created_at", null: false
30 | t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
31 | t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
32 | end
33 |
34 | create_table "active_storage_blobs", force: :cascade do |t|
35 | t.string "key", null: false
36 | t.string "filename", null: false
37 | t.string "content_type"
38 | t.text "metadata"
39 | t.string "service_name", null: false
40 | t.bigint "byte_size", null: false
41 | t.string "checksum"
42 | t.datetime "created_at", null: false
43 | t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
44 | end
45 |
46 | create_table "active_storage_variant_records", force: :cascade do |t|
47 | t.bigint "blob_id", null: false
48 | t.string "variation_digest", null: false
49 | t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
50 | end
51 |
52 | create_table "answers", force: :cascade do |t|
53 | t.bigint "question_id", null: false
54 | t.string "content"
55 | t.string "profile"
56 | t.datetime "created_at", null: false
57 | t.datetime "updated_at", null: false
58 | t.index ["question_id"], name: "index_answers_on_question_id"
59 | end
60 |
61 | create_table "questions", force: :cascade do |t|
62 | t.string "content"
63 | t.string "photo"
64 | t.datetime "created_at", null: false
65 | t.datetime "updated_at", null: false
66 | end
67 |
68 | create_table "searches", force: :cascade do |t|
69 | t.string "state"
70 | t.string "party"
71 | t.string "gender"
72 | t.string "race"
73 | t.datetime "created_at", null: false
74 | t.datetime "updated_at", null: false
75 | t.string "name"
76 | t.string "role"
77 | end
78 |
79 | create_table "user_answers", force: :cascade do |t|
80 | t.bigint "user_id", null: false
81 | t.bigint "answer_id", null: false
82 | t.integer "weight"
83 | t.datetime "created_at", null: false
84 | t.datetime "updated_at", null: false
85 | t.index ["answer_id"], name: "index_user_answers_on_answer_id"
86 | t.index ["user_id"], name: "index_user_answers_on_user_id"
87 | end
88 |
89 | create_table "users", force: :cascade do |t|
90 | t.string "email", default: "", null: false
91 | t.string "encrypted_password", default: "", null: false
92 | t.string "reset_password_token"
93 | t.datetime "reset_password_sent_at"
94 | t.datetime "remember_created_at"
95 | t.datetime "created_at", null: false
96 | t.datetime "updated_at", null: false
97 | t.string "name"
98 | t.string "role"
99 | t.string "state"
100 | t.string "party"
101 | t.string "race"
102 | t.string "gender"
103 | t.string "orientation", default: ""
104 | t.index ["email"], name: "index_users_on_email", unique: true
105 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
106 | end
107 |
108 | add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
109 | add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
110 | add_foreign_key "answers", "questions"
111 | add_foreign_key "user_answers", "answers"
112 | add_foreign_key "user_answers", "users"
113 | end
114 |
--------------------------------------------------------------------------------
/lib/assets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lanarosatech/elect/a3971d0f3a97cdf45507ca41e492f2fd6d9d93a6/lib/assets/.keep
--------------------------------------------------------------------------------
/lib/tasks/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lanarosatech/elect/a3971d0f3a97cdf45507ca41e492f2fd6d9d93a6/lib/tasks/.keep
--------------------------------------------------------------------------------
/lib/templates/erb/scaffold/_form.html.erb:
--------------------------------------------------------------------------------
1 | <%# frozen_string_literal: true %>
2 | <%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
3 | <%%= f.error_notification %>
4 | <%%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
5 |
6 |