source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/admin/base_controller.rb | Ruby | mit | 4,370 | main | 869 | # rubocop:disable Rails/ApplicationController
module Admin
class BaseController < ActionController::Base
include Pagy::Backend
include CurrentTheme
before_action :authenticate_admin_user!
before_action :ensure_two_factor_enabled, if: :current_admin_user
before_action :set_current_admin_user
... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/admin/invitations_controller.rb | Ruby | mit | 4,370 | main | 1,329 | module Admin
class InvitationsController < Devise::InvitationsController
before_action :authorize_admin, only: %i[new create] # rubocop:disable Rails/LexicallyScopedActionFilter
before_action :configure_permitted_parameters
after_action :create_invited_activity, only: :create
def create
self.re... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/admin/learners_controller.rb | Ruby | mit | 4,370 | main | 945 | module Admin
class LearnersController < Admin::BaseController
before_action :authorize_admin, only: %i[destroy]
def index
if params[:search_term].present?
@pagy, @learners = pagy(User.search_by(params[:search_term]), items: 20)
else
@pagy, @learners = pagy(User.all, items: 20)
... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/admin/profile/password_controller.rb | Ruby | mit | 4,370 | main | 632 | module Admin
class Profile::PasswordController < Admin::BaseController
def update
@admin_user = AdminUser.find(current_admin_user.id)
if @admin_user.update_with_password(password_params)
# Sign in the user by passing validation in case their password changed
bypass_sign_in(@admin_user... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/admin/reports/users_controller.rb | Ruby | mit | 4,370 | main | 902 | module Admin
class Reports::UsersController < Admin::BaseController
before_action :set_date_range, only: :index
def index
@sign_up_stats = ::Reports::UserSignUpsDayStat
.for_date_range(@start, @end)
.group_by_period(period.name)
end
private
def set_date_range
@earlie... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/admin/reports/lesson_completions_controller.rb | Ruby | mit | 4,370 | main | 941 | module Admin
class Reports::LessonCompletionsController < Admin::BaseController
before_action :set_date_range, only: :show
def show
@lesson_completions_stats = ::Reports::AllLessonCompletionsDayStat
.for_date_range(@start, @end)
.group_by_period(period.name)
end
private
de... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/admin/reports/paths_controller.rb | Ruby | mit | 4,370 | main | 768 | module Admin
class Reports::PathsController < Admin::BaseController
before_action :set_date_range, only: :show
def show
@path = Path.find(params[:id])
@path_lesson_completions = @path.lesson_completion_stats
.filter_by_course(params[:course_id])
.for_date_range(@start, @end)
... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/admin/team_members/deactivation_controller.rb | Ruby | mit | 4,370 | main | 694 | module Admin
class TeamMembers::DeactivationController < Admin::BaseController
before_action :authorize_admin
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
def update
team_member = AdminUser.find(params[:team_member_id])
team_member.deactivate!
redirect_to admin_te... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/admin/team_members/role_controller.rb | Ruby | mit | 4,370 | main | 1,022 | module Admin
class TeamMembers::RoleController < Admin::BaseController
before_action :authorize_admin
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
def edit
@team_member = AdminUser.find(params[:team_member_id])
end
def update
@team_member = AdminUser.find(params... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/admin/team_members/resend_invitation_controller.rb | Ruby | mit | 4,370 | main | 867 | module Admin
class TeamMembers::ResendInvitationController < Admin::BaseController
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
def create # rubocop:disable Metrics/MethodLength
team_member = AdminUser.find(params[:team_member_id])
if team_member.awaiting_activation?
... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/admin/team_members/password_resets_controller.rb | Ruby | mit | 4,370 | main | 585 | module Admin
class TeamMembers::PasswordResetsController < Admin::BaseController
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
def create
team_member = AdminUser.find(params[:team_member_id])
team_member.send_reset_password_instructions
team_member.create_activity(key: ... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/admin/team_members/two_factor_reset_controller.rb | Ruby | mit | 4,370 | main | 829 | module Admin
class TeamMembers::TwoFactorResetController < Admin::BaseController
before_action :authorize_admin
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
def update
team_member = AdminUser.find(params[:team_member_id])
team_member.reset_two_factor!
team_member.p... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/admin/team_members/activities_controller.rb | Ruby | mit | 4,370 | main | 216 | module Admin
class TeamMembers::ActivitiesController < Admin::BaseController
def index
@activities = PublicActivity::Activity.where(trackable_type: 'AdminUser').order(created_at: :desc)
end
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/admin/team_members/reactivation_controller.rb | Ruby | mit | 4,370 | main | 776 | module Admin
class TeamMembers::ReactivationController < Admin::BaseController
before_action :authorize_admin
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
def update
team_member = AdminUser.find(params[:team_member_id])
team_member.reactivate!
team_member.reset_two... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/guides/installations_controller.rb | Ruby | mit | 4,370 | main | 267 | module Guides
class InstallationsController < ApplicationController
def index
@lessons_by_path = Lesson
.installation_lessons
.sort_by { |lesson| [lesson.course.position, lesson.path.position] }
.group_by(&:path)
end
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/guides/community_controller.rb | Ruby | mit | 4,370 | main | 532 | module Guides
class CommunityController < ApplicationController
Guide = Data.define(:title, :path)
def show
@guides = guides.map { |title, path| Guide.new(title:, path:) }
end
private
def guides
{
'Rules' => rules_guides_community_path,
'Expectations' => expectations... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/api/points_controller.rb | Ruby | mit | 4,370 | main | 935 | class Api::PointsController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :authenticate
def index
render json: Point.order(points: :desc).limit(params[:limit]).offset(params[:offset])
end
def show
user_points = Point.find_by(discord_id: params[:id])
if user... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/project_submissions/likes_controller.rb | Ruby | mit | 4,370 | main | 757 | class ProjectSubmissions::LikesController < ApplicationController
before_action :authenticate_user!
before_action :authorize_like
def update
@project_submission = ProjectSubmission.find(params[:project_submission_id])
if @project_submission.liked_by?(current_user)
@project_submission.unlike(curren... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/project_submissions/flags_controller.rb | Ruby | mit | 4,370 | main | 1,115 | class ProjectSubmissions::FlagsController < ApplicationController
before_action :authenticate_user!
before_action :set_project_submission
def new
@flag = @project_submission.flags.new
end
def create
@flag = @project_submission.flags.new(flag_params)
respond_to do |format|
if @flag.save
... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/users/registrations_controller.rb | Ruby | mit | 4,370 | main | 228 | class Users::RegistrationsController < Devise::RegistrationsController
protected
def after_sign_up_path_for(_resource)
dashboard_path
end
def after_inactive_sign_up_path_for(_resource)
dashboard_path
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/users/progress_controller.rb | Ruby | mit | 4,370 | main | 427 | module Users
class ProgressController < ApplicationController
before_action :authenticate_user!
def destroy
result = Users::ResetProgress.call(current_user)
if result.success?
redirect_to edit_users_profile_path, notice: 'Success: Your progress has been reset.'
else
redirect... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/users/profiles_controller.rb | Ruby | mit | 4,370 | main | 458 | module Users
class ProfilesController < ApplicationController
before_action :authenticate_user!
def edit; end
def update
if current_user.update(user_params)
redirect_to edit_users_profile_path, notice: 'Your account has been updated'
else
render :edit, status: :unprocessable_... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/users/omniauth_callbacks_controller.rb | Ruby | mit | 4,370 | main | 798 | class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def github
@user = UserProvider.find_user(auth)
update_users_avatar if avatar_needs_updated?
if @user.persisted?
@user.remember_me = true
sign_in_and_redirect @user
else
session['devise.github_data'] = a... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/users/paths_controller.rb | Ruby | mit | 4,370 | main | 595 | module Users
class PathsController < ApplicationController
before_action :authenticate_user!
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
def create
if current_user.update(path:)
redirect_to path, notice: "You have selected the #{path.title} path"
else
red... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | app/controllers/github/webhooks_controller.rb | Ruby | mit | 4,370 | main | 390 | class Github::WebhooksController < ApplicationController
include GithubWebhook::Processor
skip_before_action :verify_authenticity_token
def github_push(payload)
event = ::Github::PushEvent.new(payload)
Lessons::UpdateContentJob.perform_later(event.modified_urls) if event.merged_to_main?
end
privat... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/application.rb | Ruby | mit | 4,370 | main | 1,280 | require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Theodinproject
class Application < Rails::Application
# Initialize configuration defaults for originally generated ... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/routes.rb | Ruby | mit | 4,370 | main | 2,804 | Rails.application.routes.draw do
match '/404' => 'errors#not_found', via: :all
match '422' => 'errors#unprocessable_entity', via: :all
match '500' => 'errors#internal_server_error', via: :all
get 'up' => 'rails/health#show', as: :rails_health_check
draw(:redirects)
if Rails.env.development?
mount Loo... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/puma_development.rb | Ruby | mit | 4,370 | main | 1,788 | # Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/boot.rb | Ruby | mit | 4,370 | main | 207 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations. |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/puma.rb | Ruby | mit | 4,370 | main | 2,520 | # This configuration file will be evaluated by Puma. The top-level methods that
# are invoked here are part of Puma's configuration DSL. For more information
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
#
# Puma starts a configurable number of processes (workers) and each process
# serve... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/ci.rb | Ruby | mit | 4,370 | main | 559 | # Run using bin/ci
CI.run do
# TODO: Consider adding bin/setup
step 'Style: Ruby', 'bin/rubocop'
step 'Style: ERB', 'bin/erb_lint --lint-all'
step 'Style: Standard JS', 'bin/yarn lint'
step 'Style: Stylelint CSS', 'bin/yarn run stylelint'
step 'Security: Gem audit', 'bin/bundler-audit'
step 'Security: ... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/environments/development.rb | Ruby | mit | 4,370 | main | 3,948 | require 'active_support/core_ext/integer/time'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Make code changes take effect immediately without server restart.
config.enable_reloading = true
# Do not eager load code on boot.
config.eager... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/environments/test.rb | Ruby | mit | 4,370 | main | 3,018 | # The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.application.configure do
# Settings... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/environments/production.rb | Ruby | mit | 4,370 | main | 3,844 | require 'active_support/core_ext/integer/time'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
routes.default_url_options = { host: 'www.theodinproject.com', protocol: '... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/initializers/smtp.rb | Ruby | mit | 4,370 | main | 318 | Rails.application.config.after_initialize do
ActionMailer::Base.smtp_settings = {
address: ENV['MAILGUN_SMTP_SERVER'],
port: ENV['MAILGUN_SMTP_PORT'],
authentication: :plain,
user_name: ENV['MAILGUN_SMTP_LOGIN'],
password: ENV['MAILGUN_SMTP_PASSWORD'],
domain: ENV['MAILGUN_DOMAIN'],
}
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/initializers/backtrace_silencers.rb | Ruby | mit | 4,370 | main | 540 | # Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) }
# You can also remove all the silencers if you're trying to debug a ... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/initializers/permissions_policy.rb | Ruby | mit | 4,370 | main | 480 | # Be sure to restart your server when you modify this file.
# Define an application-wide HTTP permissions policy. For further
# information see: https://developers.google.com/web/updates/2018/06/feature-policy
# Rails.application.config.permissions_policy do |policy|
# policy.camera :none
# policy.gyroscope ... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/initializers/friendly_id.rb | Ruby | mit | 4,370 | main | 3,091 | # FriendlyId Global Configuration
#
# Use this to set up shared configuration options for your entire application.
# Any of the configuration options shown here can also be applied to single
# models by passing arguments to the `friendly_id` class method or defining
# methods in your model.
#
# To learn more, check out... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/initializers/sidekiq.rb | Ruby | mit | 4,370 | main | 373 | Sidekiq.configure_server do |config|
config.redis = { url: ENV['REDIS_URL'], ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE } }
end
Sidekiq.configure_client do |config|
config.redis = { url: ENV['REDIS_URL'], ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE } }
end
Sidekiq.configure_client do |config|
... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/initializers/filter_parameter_logging.rb | Ruby | mit | 4,370 | main | 462 | # Be sure to restart your server when you modify this file.
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
# Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for supported notations and behavio... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/initializers/rack_attack.rb | Ruby | mit | 4,370 | main | 2,942 | class Rack::Attack
# Rack::Attack.cache.store = Redis.new(url: ENV['REDIS_FOR_RACK_ATTACK_URL']) if ENV['REDIS_FOR_RACK_ATTACK_URL']
### Throttle Spammy Clients ###
# If any single client IP is making tons of requests, then they're
# probably malicious or a poorly-configured scraper. Either way, they
# don'... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/initializers/cookies_serializer.rb | Ruby | mit | 4,370 | main | 246 | # Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :hybrid |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/initializers/content_security_policy.rb | Ruby | mit | 4,370 | main | 1,332 | # Be sure to restart your server when you modify this file.
# Define an application-wide content security policy.
# See the Securing Rails Applications Guide for more information:
# https://guides.rubyonrails.org/security.html#content-security-policy-header
# Rails.application.configure do
# config.content_security... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/initializers/patch_enable_extension.rb | Ruby | mit | 4,370 | main | 641 | require 'active_record/connection_adapters/postgresql_adapter'
# NOTE: patch for https://devcenter.heroku.com/changelog-items/2446
# Source: https://stackoverflow.com/questions/73214844/error-extension-btree-gist-must-be-installed-in-schema-heroku-ext/73289426#73289426
module EnableExtensionHerokuPatch
def enable_ex... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/initializers/devise.rb | Ruby | mit | 4,370 | main | 14,471 | # rubocop:disable Lint/MissingCopEnableDirective, Layout/LineLength
Devise.setup do |config|
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
config.mailer_sender = ... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/initializers/sentry.rb | Ruby | mit | 4,370 | main | 535 | Sentry.init do |config|
config.dsn = ENV['SENTRY_DSN']
config.enabled_environments = %w[production]
config.breadcrumbs_logger = %i[active_support_logger http_logger]
config.send_default_pii = true
# enable tracing
config.traces_sample_rate = 0.1
# enable profiling
# this is relative to traces_sample_r... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/initializers/pagy.rb | Ruby | mit | 4,370 | main | 10,986 | # frozen_string_literal: true
# Pagy initializer file (5.10.1)
# Customize only what you really need and notice that the core Pagy works also without any of the following lines.
# Should you just cherry pick part of this file, please maintain the require-order of the extras
# Pagy DEFAULT Variables
# See https://ddne... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/initializers/assets.rb | Ruby | mit | 4,370 | main | 296 | # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/routes/redirects.rb | Ruby | mit | 4,370 | main | 390 | require_relative 'redirectors/nested_lesson_redirector'
Rails.application.routes.draw do
get '/courses/web-development-101(/lessons/:id)', to: redirect('/paths/foundations')
get '/paths/:path_id/courses/:course_id/lessons/:id', to: redirect(Redirectors::NestedLessonRedirector.new)
get '/discord', to: redirect(ODI... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/routes/admin.rb | Ruby | mit | 4,370 | main | 1,669 | require 'sidekiq/web'
require 'sidekiq/cron/web'
devise_for :admin_users, path: :admin, module: :admin
namespace :admin do # rubocop:disable Metrics/BlockLength
root to: 'dashboard#show'
resource :dashboard, only: :show, controller: :dashboard
authenticate :admin_user do
mount Sidekiq::Web => '/sidekiq'
... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | config/routes/redirectors/nested_lesson_redirector.rb | Ruby | mit | 4,370 | main | 419 | module Redirectors
class NestedLessonRedirector
def call(params, request)
path = lesson_path(params[:course_id], params[:id])
"http://#{request.host_with_port}/#{path}"
end
private
def lesson_path(course_id, lesson_id)
lesson = ::Course.find(course_id).lessons.find(lesson_id)
... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/seeds.rb | Ruby | mit | 4,370 | main | 1,105 | # load all lessons
load './db/fixtures/lessons/foundation_lessons.rb'
load './db/fixtures/lessons/ruby_lessons.rb'
load './db/fixtures/lessons/database_lessons.rb'
load './db/fixtures/lessons/ruby_on_rails_lessons.rb'
load './db/fixtures/lessons/html_and_css_lessons.rb'
load './db/fixtures/lessons/javascript_lessons.rb... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/schema.rb | Ruby | mit | 4,370 | main | 19,250 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rai... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20230122034120_add_service_name_to_active_storage_blobs.active_storage.rb | Ruby | mit | 4,370 | main | 806 | # This migration comes from active_storage (originally 20190112182829)
class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
def up
return unless table_exists?(:active_storage_blobs)
unless column_exists?(:active_storage_blobs, :service_name)
add_column :active_storage_blobs, :service... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20210622162155_add_course_id_to_lessons.rb | Ruby | mit | 4,370 | main | 505 | class AddCourseIdToLessons < ActiveRecord::Migration[6.1]
def change
add_reference :lessons, :course, index: true
add_foreign_key :lessons, :courses
remove_index :lessons, %i[identifier_uuid section_id], unique: true
add_index :lessons, %i[identifier_uuid course_id], unique: true
sql = %(
... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20240709052504_add_reactivation_to_admin_user.rb | Ruby | mit | 4,370 | main | 232 | class AddReactivationToAdminUser < ActiveRecord::Migration[7.0]
def change
add_column :admin_users, :reactivated_at, :datetime
add_reference :admin_users, :reactivated_by, foreign_key: { to_table: :admin_users }
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20231121083403_create_admin_users.rb | Ruby | mit | 4,370 | main | 820 | class CreateAdminUsers < ActiveRecord::Migration[7.0]
def change
create_table :admin_users do |t|
## Database authenticatable
t.string :name, null: false, default: ''
t.string :email, null: false, default: ''
t.string :encrypted_password, null: false, default: ''
## Recoverable
... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20240117115443_add_lesson_and_project_counts_to_courses.rb | Ruby | mit | 4,370 | main | 286 | class AddLessonAndProjectCountsToCourses < ActiveRecord::Migration[7.0]
def change
add_column :courses, :lessons_count, :integer, default: 0, null: false # rubocop:disable Rails/BulkChangeTable
add_column :courses, :projects_count, :integer, default: 0, null: false
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20240713134127_add_users_counter_to_paths.rb | Ruby | mit | 4,370 | main | 218 | class AddUsersCounterToPaths < ActiveRecord::Migration[7.0]
def up
add_column :paths, :users_count, :integer, default: 0
Path.find_each do |path|
Path.reset_counters(path.id, :users)
end
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20220915061812_remove_user_confirmation_columns.rb | Ruby | mit | 4,370 | main | 239 | class RemoveUserConfirmationColumns < ActiveRecord::Migration[6.1]
def change
remove_columns :users, :confirmation_token, :confirmed_at, :confirmation_sent_at, :unconfirmed_email # rubocop:disable Rails/ReversibleMigration
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20240806054115_rename_announcement_admin_user.rb | Ruby | mit | 4,370 | main | 266 | class RenameAnnouncementAdminUser < ActiveRecord::Migration[7.0]
def change
remove_column :announcements, :user_id, :bigint
rename_column :announcements, :admin_user_id, :created_by_id
change_column_null :announcements, :created_by_id, false
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20220504125616_add_show_on_homepage_flag_and_badge_uri_to_courses.rb | Ruby | mit | 4,370 | main | 269 | class AddShowOnHomepageFlagAndBadgeUriToCourses < ActiveRecord::Migration[6.1]
def change
add_column :courses, :show_on_homepage, :boolean, default: false, null: false # rubocop:disable Rails/BulkChangeTable
add_column :courses, :badge_uri, :string
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20240801070241_add_roles_to_admin_users.rb | Ruby | mit | 4,370 | main | 209 | class AddRolesToAdminUsers < ActiveRecord::Migration[7.0]
def change
create_enum :admin_roles, %w[moderator maintainer core]
add_column :admin_users, :role, :enum, enum_type: :admin_roles
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20240622210239_devise_invitable_add_to_admin_users.rb | Ruby | mit | 4,370 | main | 873 | class DeviseInvitableAddToAdminUsers < ActiveRecord::Migration[7.0]
def up
change_table :admin_users do |t| # rubocop:disable Rails/BulkChangeTable
t.string :invitation_token
t.datetime :invitation_created_at
t.datetime :invitation_sent_at
t.datetime :invitation_accepted_at
... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20240704102438_add_deactivated_to_admin_users.rb | Ruby | mit | 4,370 | main | 232 | class AddDeactivatedToAdminUsers < ActiveRecord::Migration[7.0]
def change
add_column :admin_users, :deactivated_at, :datetime
add_reference :admin_users, :deactivated_by, foreign_key: { to_table: :admin_users }
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20240530151357_change_flipper_gates_value_to_text.rb | Ruby | mit | 4,370 | main | 597 | # frozen_string_literal: true
class ChangeFlipperGatesValueToText < ActiveRecord::Migration[7.0]
def up
# Ensure this incremental update migration is idempotent
return unless connection.column_exists? :flipper_gates, :value, :string
if index_exists? :flipper_gates, %i[feature_key key value]
remove... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20240720081643_add_devise_two_factor_to_admin_users.rb | Ruby | mit | 4,370 | main | 366 | class AddDeviseTwoFactorToAdminUsers < ActiveRecord::Migration[7.0]
def change
add_column :admin_users, :otp_secret, :string # rubocop:disable Rails/BulkChangeTable
add_column :admin_users, :consumed_timestep, :integer
add_column :admin_users, :otp_required_for_login, :boolean, default: false # rubocop:di... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20250215224143_create_interview_surveys.rb | Ruby | mit | 4,370 | main | 253 | class CreateInterviewSurveys < ActiveRecord::Migration[7.1]
def change
create_table :interview_surveys do |t|
t.references :user, null: false, foreign_key: true
t.date :interview_date, null: false
t.timestamps
end
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20240726181456_add_reactivated_to_admin_user.rb | Ruby | mit | 4,370 | main | 402 | # rubocop:disable Rails/ReversibleMigration
class AddReactivatedToAdminUser < ActiveRecord::Migration[7.0]
def change
execute <<-SQL.squish
ALTER TYPE status RENAME TO admin_user_status;
ALTER TYPE admin_user_status RENAME VALUE 'active' TO 'activated';
ALTER TYPE admin_user_status ADD VALUE 'pe... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20250212143446_add_search_ts_vector_column_to_users.rb | Ruby | mit | 4,370 | main | 564 | # rubocop:disable Rails/ReversibleMigration
class AddSearchTsVectorColumnToUsers < ActiveRecord::Migration[7.1]
disable_ddl_transaction!
def change
execute <<-SQL.squish
ALTER TABLE users
ADD COLUMN search_tsvector tsvector GENERATED ALWAYS AS (
setweight(to_tsvector('english', coalesce(ema... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20210712195824_add_url_and_message_to_notifications.rb | Ruby | mit | 4,370 | main | 311 | class AddUrlAndMessageToNotifications < ActiveRecord::Migration[6.1]
def change
add_column :notifications, :url, :string, null: false # rubocop:disable Rails/BulkChangeTable, Rails/NotNullColumn
add_column :notifications, :message, :text, null: false # rubocop:disable Rails/NotNullColumn
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20230122034122_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb | Ruby | mit | 4,370 | main | 292 | # This migration comes from active_storage (originally 20211119233751)
class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0]
def change
return unless table_exists?(:active_storage_blobs)
change_column_null(:active_storage_blobs, :checksum, true)
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20240626164023_add_status_to_admin_users.rb | Ruby | mit | 4,370 | main | 236 | class AddStatusToAdminUsers < ActiveRecord::Migration[7.0]
def change
create_enum :status, %w[pending active deactivated]
add_column :admin_users, :status, :enum, enum_type: :status, default: 'pending', null: false
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20230527165350_create_flipper_tables.rb | Ruby | mit | 4,370 | main | 578 | class CreateFlipperTables < ActiveRecord::Migration[7.0]
def self.up
create_table :flipper_features do |t|
t.string :key, null: false
t.timestamps null: false
end
add_index :flipper_features, :key, unique: true
create_table :flipper_gates do |t|
t.string :feature_key, null: false
... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20220129182526_add_installation_lesson_column_to_lessons.rb | Ruby | mit | 4,370 | main | 263 | class AddInstallationLessonColumnToLessons < ActiveRecord::Migration[6.1]
def change
add_column :lessons, :installation_lesson, :boolean, default: false # rubocop:disable Rails/ThreeStateBooleanColumn
add_index :lessons, :installation_lesson
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20250215230748_create_interview_survey_concepts.rb | Ruby | mit | 4,370 | main | 308 | class CreateInterviewSurveyConcepts < ActiveRecord::Migration[7.1]
def change
create_table :interview_survey_concepts do |t|
t.references :interview_survey, null: false, foreign_key: true
t.references :interview_concept, null: false, foreign_key: true
t.timestamps
end
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20240723065559_create_activities.rb | Ruby | mit | 4,370 | main | 684 | # frozen_string_literal: true
# Migration responsible for creating a table with activities
class CreateActivities < ActiveRecord::Migration[6.1]
def self.up
create_table :activities do |t|
t.belongs_to :trackable, polymorphic: true
t.belongs_to :owner, polymorphic: true
t.string :key
t.js... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20230122034121_create_active_storage_variant_records.active_storage.rb | Ruby | mit | 4,370 | main | 1,084 | # This migration comes from active_storage (originally 20191206030411)
class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
def change
return unless table_exists?(:active_storage_blobs)
# Use Active Record's configured type for primary key
create_table :active_storage_variant_records, i... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20221014124812_create_contents.rb | Ruby | mit | 4,370 | main | 227 | class CreateContents < ActiveRecord::Migration[6.1]
def change
create_table :contents do |t|
t.text :body, null: false
t.belongs_to :lesson, foreign_key: true, null: false
t.timestamps
end
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20230805091337_rename_votes_table_to_likes.rb | Ruby | mit | 4,370 | main | 1,697 | class RenameVotesTableToLikes < ActiveRecord::Migration[7.0]
def up
rename_table :votes, :likes
rename_column :likes, :votable_id, :likeable_id
rename_column :likes, :votable_type, :likeable_type
rename_column :likes, :voter_id, :user_id
change_column_null :likes, :likeable_id, false # rubocop:d... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20240805080849_rename_flag_admin_user_to_resolved_by.rb | Ruby | mit | 4,370 | main | 202 | class RenameFlagAdminUserToResolvedBy < ActiveRecord::Migration[7.0]
def change
remove_column :flags, :resolved_by_id, :integer
rename_column :flags, :admin_user_id, :resolved_by_id
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/migrate/20220414212627_rename_announcements_expires_column.rb | Ruby | mit | 4,370 | main | 207 | class RenameAnnouncementsExpiresColumn < ActiveRecord::Migration[6.1]
def change
rename_column :announcements, :expires, :expires_at
change_column_null :announcements, :expires_at, false
end
end |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/seeds/test_project_submissions.rb | Ruby | mit | 4,370 | main | 659 | if Rails.env.development? || ENV['STAGING']
ActiveJob::Base.queue_adapter = :inline
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = false
users = (1..20).map do |number|
User.find_or_create_by(email: "test_user_#{number}@email.com") do |user|
user.username = "test_u... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/seeds/success_stories.rb | Ruby | mit | 4,370 | main | 8,221 | success_stories = [
{
student_name: 'Rob Pando',
avatar_path_name: 'rob_pando.jpg',
story_content: '<p>TOP was a perfect match for my learning style. Not walking me through an entire project but actually forcing me to figure it out on my own, by pointing me in all the right directions in order to complete... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/seeds/test_users_and_admins.rb | Ruby | mit | 4,370 | main | 511 | if Rails.env.development? || ENV['STAGING']
names = %w[kevin rachel austin sully tatiana briggs leo grace asartea manon tester]
names.each do |name|
User.find_or_create_by!(email: "#{name}@odin.com") do |user|
user.username = name
user.password = 'password'
end
end
AdminUser.find_or_create... |
github | TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject | db/seeds/feature_flags.rb | Ruby | mit | 4,370 | main | 755 | FEATURE_FLAGS = %i[survey_feature].freeze
# Add any new feature flags
FEATURE_FLAGS.each do |flag|
next if Flipper.exist?(flag)
Rails.logger.debug { "🚀 Adding feature flag: #{flag}" }
Flipper.add(flag)
end
# By default, always enable feature flags in development and staging environments
if Rails.env.developme... |
github | binarylogic/authlogic | https://github.com/binarylogic/authlogic | Rakefile | Ruby | mit | 4,346 | master | 444 | # frozen_string_literal: true
require "rubygems"
require "bundler"
Bundler.setup
require "rake/testtask"
Rake::TestTask.new(:test) do |test|
test.libs << "test"
test.pattern = "test/**/*_test.rb"
test.verbose = false
# Set interpreter warning level to 2 (verbose)
test.ruby_opts << "-W2"
end
require "rubo... |
github | binarylogic/authlogic | https://github.com/binarylogic/authlogic | authlogic.gemspec | Ruby | mit | 4,346 | master | 2,152 | # frozen_string_literal: true
require "English"
require_relative "lib/authlogic/version"
::Gem::Specification.new do |s|
s.name = "authlogic"
s.version = ::Authlogic.gem_version.to_s
s.platform = ::Gem::Platform::RUBY
s.authors = [
"Ben Johnson",
"Tieg Zaharia",
"Jared Beck"
]
s.email = [
... |
github | binarylogic/authlogic | https://github.com/binarylogic/authlogic | test/i18n_test.rb | Ruby | mit | 4,346 | master | 907 | # frozen_string_literal: true
require "test_helper"
class I18nTest < ActiveSupport::TestCase
def test_uses_authlogic_as_scope_by_default
assert_equal :authlogic, Authlogic::I18n.scope
end
def test_can_set_scope
assert_nothing_raised { Authlogic::I18n.scope = %i[a b] }
assert_equal %i[a b], Authlogi... |
github | binarylogic/authlogic | https://github.com/binarylogic/authlogic | test/config_test.rb | Ruby | mit | 4,346 | master | 901 | # frozen_string_literal: true
require "test_helper"
class ConfigTest < ActiveSupport::TestCase
def setup
@klass = Class.new {
extend Authlogic::Config
def self.foobar(value = nil)
rw_config(:foobar_field, value, "default_foobar")
end
}
@subklass = Class.new(@klass)
end
d... |
github | binarylogic/authlogic | https://github.com/binarylogic/authlogic | test/adapter_test.rb | Ruby | mit | 4,346 | master | 1,623 | # frozen_string_literal: true
require "test_helper"
require "authlogic/controller_adapters/rails_adapter"
module Authlogic
module ControllerAdapters
class AbstractAdapterTest < ActiveSupport::TestCase
def test_controller
controller = Class.new(MockController) do
def controller.an_arbitra... |
github | binarylogic/authlogic | https://github.com/binarylogic/authlogic | test/random_test.rb | Ruby | mit | 4,346 | master | 414 | # frozen_string_literal: true
require "test_helper"
class RandomTest < ActiveSupport::TestCase
def test_that_hex_tokens_are_unique
tokens = Array.new(100) { Authlogic::Random.hex_token }
assert_equal tokens.size, tokens.uniq.size
end
def test_that_friendly_tokens_are_unique
tokens = Array.new(100) ... |
github | binarylogic/authlogic | https://github.com/binarylogic/authlogic | test/test_helper.rb | Ruby | mit | 4,346 | master | 8,482 | # frozen_string_literal: true
require "coveralls"
require "simplecov"
require "simplecov-console"
Coveralls.wear!
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
[
SimpleCov::Formatter::Console,
# Want a nice code coverage website? Uncomment this next line!
SimpleCov::Formatter::HTMLFor... |
github | binarylogic/authlogic | https://github.com/binarylogic/authlogic | test/session_test/password_test.rb | Ruby | mit | 4,346 | master | 4,815 | # frozen_string_literal: true
require "test_helper"
module SessionTest
module PasswordTest
class ConfigTest < ActiveSupport::TestCase
def test_find_by_login_method_is_deprecated
expected_warning = Regexp.new(
Regexp.escape(::Authlogic::Session::Base::E_DPR_FIND_BY_LOGIN_METHOD)
)... |
github | binarylogic/authlogic | https://github.com/binarylogic/authlogic | test/session_test/params_test.rb | Ruby | mit | 4,346 | master | 1,968 | # frozen_string_literal: true
require "test_helper"
module SessionTest
module ParamsTest
class ConfigTest < ActiveSupport::TestCase
def test_params_key
UserSession.params_key = "my_params_key"
assert_equal "my_params_key", UserSession.params_key
UserSession.params_key "user_creden... |
github | binarylogic/authlogic | https://github.com/binarylogic/authlogic | test/session_test/cookies_test.rb | Ruby | mit | 4,346 | master | 8,370 | # frozen_string_literal: true
require "test_helper"
module SessionTest
module CookiesTest
class ConfigTest < ActiveSupport::TestCase
def test_cookie_key
UserSession.cookie_key = "my_cookie_key"
assert_equal "my_cookie_key", UserSession.cookie_key
UserSession.cookie_key "user_crede... |
github | binarylogic/authlogic | https://github.com/binarylogic/authlogic | test/session_test/existence_test.rb | Ruby | mit | 4,346 | master | 2,622 | # frozen_string_literal: true
require "test_helper"
module SessionTest
module ExistenceTest
class ClassMethodsTest < ActiveSupport::TestCase
def test_create_with_good_credentials
ben = users(:ben)
session = UserSession.create(login: ben.login, password: "benrocks")
refute session.n... |
github | binarylogic/authlogic | https://github.com/binarylogic/authlogic | test/session_test/activation_test.rb | Ruby | mit | 4,346 | master | 1,326 | # frozen_string_literal: true
require "test_helper"
module SessionTest
module ActivationTest
class ClassMethodsTest < ActiveSupport::TestCase
def test_activated
assert UserSession.activated?
Authlogic::Session::Base.controller = nil
refute UserSession.activated?
end
de... |
github | binarylogic/authlogic | https://github.com/binarylogic/authlogic | test/session_test/magic_columns_test.rb | Ruby | mit | 4,346 | master | 1,978 | # frozen_string_literal: true
require "test_helper"
module SessionTest
module MagicColumnsTest
class ConfigTest < ActiveSupport::TestCase
def test_last_request_at_threshold_config
UserSession.last_request_at_threshold = 2.minutes
assert_equal 2.minutes, UserSession.last_request_at_threshol... |
github | binarylogic/authlogic | https://github.com/binarylogic/authlogic | test/session_test/magic_states_test.rb | Ruby | mit | 4,346 | master | 1,720 | # frozen_string_literal: true
require "test_helper"
module SessionTest
module SessionTest
class ConfigTest < ActiveSupport::TestCase
def test_disable_magic_states_config
UserSession.disable_magic_states = true
assert_equal true, UserSession.disable_magic_states
UserSession.disable... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.