repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/logo_component.rb | app/components/logo_component.rb | class LogoComponent < ApplicationComponent
def initialize(classes:, path: nil)
@classes = classes
@path = path
end
attr_reader :classes
def redirect_to_path
@path || root_path
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/pagination_component.rb | app/components/pagination_component.rb | class PaginationComponent < ApplicationComponent
def initialize(pagy:, resource_name:)
@pagy = pagy
@resource_name = resource_name
end
def render?
pagy.pages > 1
end
private
attr_reader :pagy, :resource_name
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/sort_component.rb | app/components/sort_component.rb | class SortComponent < ApplicationComponent
def initialize(options:, selected: {})
@options = options
@selected = selected
end
def selected_option
options.find { |option| selected?(option) } || default_option
end
def default_option
options.find { |option| option[:default] }
end
private
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/application_component.rb | app/components/application_component.rb | class ApplicationComponent < ViewComponent::Base
include Turbo::FramesHelper
delegate :inline_svg_tag, :inline_svg, to: :helpers
class << self
attr_reader :class_variants
def style(&)
@class_variants = ClassVariants.build(&)
end
end
def classes_for(slot)
self.class.class_variants.ren... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/notification_component.rb | app/components/notification_component.rb | class NotificationComponent < ApplicationComponent
def initialize(notification:)
@notification = notification
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/card_component.rb | app/components/card_component.rb | class CardComponent < ApplicationComponent
renders_one :header, Card::HeaderComponent
renders_one :body, Card::BodyComponent
renders_one :footer, Card::FooterComponent
def initialize(classes: '', id: '')
@classes = classes
@id = id
end
private
attr_reader :classes, :id
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/lesson_group_component.rb | app/components/lesson_group_component.rb | class LessonGroupComponent < ApplicationComponent
def initialize(title:, lessons:, current_user: nil)
@title = title
@lessons = lessons
@current_user = current_user
end
private
attr_reader :title, :lessons, :current_user
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/content_container_component.rb | app/components/content_container_component.rb | class ContentContainerComponent < ApplicationComponent
renders_one :footer
def initialize(classes: '', data_attributes: {})
@classes = classes
@data_attributes = data_attributes
end
private
attr_reader :classes, :data_attributes
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/charts/line_chart_component.rb | app/components/charts/line_chart_component.rb | class Charts::LineChartComponent < ApplicationComponent
def initialize(labels:, datasets:, options: {}, display_x_labels: true)
@labels = labels
@datasets = datasets
@options = options
@display_x_labels = ActiveModel::Type::Boolean.new.cast(display_x_labels)
end
def data
{
labels:,
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/charts/horizontal_bar_chart_component.rb | app/components/charts/horizontal_bar_chart_component.rb | class Charts::HorizontalBarChartComponent < ApplicationComponent
NORMAL_BAR_THICKNESS = 25
SMALL_DATASET_BAR_THICKNESS = 40
def initialize(labels:, datasets:, options: {})
@labels = labels
@datasets = datasets
@options = options
end
def data
{
labels:,
datasets:
}
end
de... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/project_submissions/user_solution_component.rb | app/components/project_submissions/user_solution_component.rb | module ProjectSubmissions
class UserSolutionComponent < ApplicationComponent
with_collection_parameter :project_submission
def initialize(project_submission:)
@project_submission = project_submission
end
def render?
project_submission.present?
end
private
attr_reader :proje... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/project_submissions/item_component.rb | app/components/project_submissions/item_component.rb | module ProjectSubmissions
class ItemComponent < ApplicationComponent
with_collection_parameter :project_submission
def initialize(project_submission:)
@project_submission = project_submission
end
def render?
project_submission.present?
end
private
attr_reader :project_submi... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/project_submissions/like_component.rb | app/components/project_submissions/like_component.rb | module ProjectSubmissions
class LikeComponent < ApplicationComponent
def initialize(project_submission:, current_users_submission: false)
@project_submission = project_submission
@current_users_submission = current_users_submission
end
private
attr_reader :project_submission, :current_us... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/complete/icon_component.rb | app/components/complete/icon_component.rb | class Complete::IconComponent < ApplicationComponent
def initialize(lesson:, current_user:, animate: false)
@lesson = lesson
@current_user = current_user
@animate = animate
end
def render?
current_user.present?
end
private
attr_reader :lesson, :current_user, :animate
def animation_clas... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/complete/button_component.rb | app/components/complete/button_component.rb | class Complete::ButtonComponent < ApplicationComponent
def initialize(lesson:, animate: false)
@lesson = lesson
@animate = animate
end
private
attr_reader :lesson, :animate
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/user/learning_goal_component.rb | app/components/user/learning_goal_component.rb | class User::LearningGoalComponent < ApplicationComponent
def initialize(current_user:)
@current_user = current_user
end
def learning_goal
current_user.learning_goal.presence || settings_link
end
private
attr_reader :current_user
def settings_link
link_to(
"What's your learning goal?"... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/user/avatar_component.rb | app/components/user/avatar_component.rb | class User::AvatarComponent < ApplicationComponent
def initialize(current_user:, classes:)
@current_user = current_user
@classes = classes
end
private
attr_reader :current_user, :classes
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/user/profile_dropdown_component.rb | app/components/user/profile_dropdown_component.rb | class User::ProfileDropdownComponent < ApplicationComponent
include Turbo::FramesHelper
delegate :current_theme, to: :helpers
def initialize(current_user:)
@current_user = current_user
end
private
attr_reader :current_user
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/vertical_navigation/item_component.rb | app/components/vertical_navigation/item_component.rb | class VerticalNavigation::ItemComponent < ApplicationComponent
style do
variant type: :active do
slot :link, class: 'bg-gray-200 text-gray-900 dark:bg-gray-700/50 dark:text-gray-300'
slot :icon, class: 'text-gray-500 group-hover:text-gray-700 dark:text-gray-300 dark:group-hover:text-gray-300'
end
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/vertical_navigation/container_component.rb | app/components/vertical_navigation/container_component.rb | class VerticalNavigation::ContainerComponent < ApplicationComponent
renders_many :links, 'VerticalNavigation::ItemComponent'
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/nav/item_component.rb | app/components/nav/item_component.rb | class Nav::ItemComponent < ApplicationComponent
def initialize(path:, text:, test_id:, icon_path: nil, options: {})
@path = path
@text = text
@test_id = test_id
@icon_path = icon_path
@options = options
end
def active?
current_page?(path)
end
private
attr_reader :path, :text, :tes... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/about_page/belief_component.rb | app/components/about_page/belief_component.rb | class AboutPage::BeliefComponent < ApplicationComponent
with_collection_parameter :belief
def initialize(belief:)
@belief = belief
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/card/header_component.rb | app/components/card/header_component.rb | module Card
class HeaderComponent < ApplicationComponent
def initialize(classes: '')
@classes = classes
end
private
attr_reader :classes
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/card/footer_component.rb | app/components/card/footer_component.rb | module Card
class FooterComponent < ApplicationComponent
def initialize(classes: '')
@classes = classes
end
private
attr_reader :classes
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/card/body_component.rb | app/components/card/body_component.rb | module Card
class BodyComponent < ApplicationComponent
def initialize(classes: '')
@classes = classes
end
private
attr_reader :classes
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/flags/action_button_component.rb | app/components/flags/action_button_component.rb | class Flags::ActionButtonComponent < ApplicationComponent
def initialize(flag:)
@flag = flag
end
def render?
@flag.active?
end
private
attr_reader :flag
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/course/badge_component.rb | app/components/course/badge_component.rb | class Course::BadgeComponent < ApplicationComponent
delegate :user_signed_in?, to: :helpers
style do
variant type: :default do
slot :default_badge, class: 'w-24 h-24 sm:w-28 sm:h-28'
end
variant type: :small do
slot :default_badge, class: 'w-24 h-24'
end
end
def initialize(course:... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/sections/lesson_component.rb | app/components/sections/lesson_component.rb | module Sections
class LessonComponent < ApplicationComponent
def initialize(lesson:, current_user:, classes: '')
@lesson = lesson
@current_user = current_user
@classes = classes
end
private
attr_reader :lesson, :current_user, :classes
def icon
if lesson.is_project?
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/forms/date_picker_component.rb | app/components/forms/date_picker_component.rb | class Forms::DatePickerComponent < ApplicationComponent
def initialize(name:, value:, min: nil, max: nil)
@name = name
@value = value
@min = min
@max = max
end
def min_date
[min, value].compact.min
end
def max_date
return max if max.present?
Time.zone.today.to_s
end
private... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/overlays/modal_component.rb | app/components/overlays/modal_component.rb | class Overlays::ModalComponent < ApplicationComponent
def initialize(title:)
@title = title
end
private
attr_reader :title
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/overlays/flash_component.rb | app/components/overlays/flash_component.rb | class Overlays::FlashComponent < ApplicationComponent
DISALLOWED_TYPES = %i[timedout].freeze
style do
variant type: :notice do
slot :bg, class: 'bg-green-100'
slot :icon, class: 'text-green-700'
slot :text, class: 'text-green-900'
slot :button,
class: 'bg-green-100 text-green... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/overlays/dialog_component.rb | app/components/overlays/dialog_component.rb | class Overlays::DialogComponent < ApplicationComponent
def initialize(id:)
@id = id
end
private
attr_reader :id
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/team/navigation_component.rb | app/components/team/navigation_component.rb | module Team
class NavigationComponent < ApplicationComponent
def initialize(roles:)
@roles = roles
end
private
attr_reader :roles
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/team/former_member_component.rb | app/components/team/former_member_component.rb | module Team
class FormerMemberComponent < ApplicationComponent
FormerTeamMember = Data.define(:name, :image, :url)
def initialize(team_member)
@team_member = FormerTeamMember.new(**team_member)
end
private
attr_reader :team_member
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/team/member_component.rb | app/components/team/member_component.rb | module Team
class MemberComponent < ApplicationComponent
Social = Data.define(:name, :url)
TeamMember = Data.define(:name, :image, :location, :joined, :socials) do
def initialize(**args)
socials = args.fetch(:socials, []).map { |social| Social.new(**social) }
location = args.fetch(:loca... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/oauth/connect_button_component.rb | app/components/oauth/connect_button_component.rb | module Oauth
class ConnectButtonComponent < ApplicationComponent
with_collection_parameter :provider
delegate :omniauth_authorize_path, to: :helpers
def initialize(provider:, resource_name:)
@provider = provider
@resource_name = resource_name
end
private
attr_reader :provider, :... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/Ui/badge_component.rb | app/components/Ui/badge_component.rb | class Ui::BadgeComponent < ApplicationComponent
def initialize(color:)
@color = color
end
def color_classes
case color
when 'yellow'
'bg-yellow-50 text-yellow-700 ring-yellow-600/20 ' \
'dark:bg-yellow-400/10 dark:text-yellow-500 dark:ring-yellow-400/20'
when 'green'
'bg-green-5... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/Ui/back_link_component.rb | app/components/Ui/back_link_component.rb | class Ui::BackLinkComponent < ApplicationComponent
def initialize(path:, name:)
@path = path
@name = name
end
private
attr_reader :path, :name
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/Ui/dropdown/component.rb | app/components/Ui/dropdown/component.rb | class Ui::Dropdown::Component < ApplicationComponent
renders_one :trigger_button, 'Ui::Dropdown::TriggerComponent'
renders_many :items
def render?
items.any?
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/Ui/dropdown/trigger_component.rb | app/components/Ui/dropdown/trigger_component.rb | class Ui::Dropdown::TriggerComponent < ApplicationComponent
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/faq/item_component.rb | app/components/faq/item_component.rb | class Faq::ItemComponent < ApplicationComponent
renders_one :question
renders_one :answer
def initialize(item:)
@item = item
end
private
attr_reader :item
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/paths/view_button_component.rb | app/components/paths/view_button_component.rb | module Paths
class ViewButtonComponent < ApplicationComponent
def initialize(current_user:, path:, classes: '')
@current_user = current_user
@path = path
@classes = classes
end
def render?
current_user.blank? || !current_user.on_path?(path)
end
private
attr_reader :c... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/paths/select_button_component.rb | app/components/paths/select_button_component.rb | module Paths
class SelectButtonComponent < ApplicationComponent
def initialize(current_user:, path:, classes: '')
@current_user = current_user
@path = path
@classes = classes
end
def render?
current_user.present?
end
private
attr_reader :current_user, :path, :classes... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/theme/switcher_component.rb | app/components/theme/switcher_component.rb | class Theme::SwitcherComponent < ApplicationComponent
style do
base do
slot :link, class: 'text-gray-600 group flex items-center dark:text-gray-300'
slot :icon,
class: 'h-5 w-5 text-gray-400 group-hover:text-gray-500 dark:text-gray-300 dark:group-hover:text-gray-300'
end
variant ty... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/progress_circle/component.rb | app/components/progress_circle/component.rb | class ProgressCircle::Component < ApplicationComponent
renders_one :icon
style do
variant type: :default do
slot :text, class: 'text-xs sm:text-sm'
slot :container_size, class: 'h-24 w-24 sm:h-28 sm:w-28'
slot :icon_size, class: 'w-20 h-20 sm:p-2 sm:w-24 sm:h-24'
end
variant type: :s... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/progress_circle/loading_component.rb | app/components/progress_circle/loading_component.rb | class ProgressCircle::LoadingComponent < ApplicationComponent
style do
variant type: :default do
slot :container_size, class: 'h-24 w-24 sm:h-28 sm:w-28'
end
variant type: :small do
slot :container_size, class: 'h-24 w-24'
end
end
def initialize(size: :default)
@size = size
end... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/components/markdown/preview_component.rb | app/components/markdown/preview_component.rb | class Markdown::PreviewComponent < ApplicationComponent
def initialize(markdown: '')
@markdown = markdown
end
def allowed_tags
Rails::HTML5::SafeListSanitizer::DEFAULT_ALLOWED_TAGS + %w[details summary section table thead tbody tr th td]
end
def allowed_attributes
Rails::HTML5::SafeListSanitizer... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/current.rb | app/models/current.rb | class Current < ActiveSupport::CurrentAttributes
attribute :admin_user
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/path.rb | app/models/path.rb | class Path < ApplicationRecord
extend FriendlyId
friendly_id :title, use: %i[slugged history finders]
has_many :users, dependent: :nullify
has_many :courses, -> { order(:position) }, dependent: :destroy, inverse_of: :path
has_many :lessons, through: :courses
has_many :path_prerequisites, dependent: :destr... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/content.rb | app/models/content.rb | class Content < ApplicationRecord
belongs_to :lesson
validates :body, presence: true
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/project_submission.rb | app/models/project_submission.rb | class ProjectSubmission < ApplicationRecord
include Discard::Model
include Likeable
before_update do
self.discard_at = nil if repo_url_changed? || live_preview_url_changed?
end
belongs_to :user
belongs_to :lesson
has_many :flags, dependent: :destroy
validates :repo_url, url: true
validates :liv... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/interview_survey_concept.rb | app/models/interview_survey_concept.rb | class InterviewSurveyConcept < ApplicationRecord
belongs_to :interview_survey
belongs_to :interview_concept
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/path_prerequisite.rb | app/models/path_prerequisite.rb | class PathPrerequisite < ApplicationRecord
belongs_to :path
belongs_to :prerequisite, class_name: 'Path'
validates :prerequisite_id, uniqueness: { scope: :path_id }
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/lesson.rb | app/models/lesson.rb | class Lesson < ApplicationRecord
extend FriendlyId
friendly_id :slug_candidates, use: %i[slugged history finders]
belongs_to :section
has_one :course, through: :section
has_one :path, through: :course
has_one :content, dependent: :destroy
has_many :project_submissions, dependent: :destroy
has_many :le... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/interview_survey.rb | app/models/interview_survey.rb | class InterviewSurvey < ApplicationRecord
belongs_to :user
has_many :interview_survey_concepts, dependent: :destroy
validates :interview_date, presence: true
validate :interview_date_must_be_in_the_past
def interview_date_must_be_in_the_past
return if interview_date.present? && interview_date <= Time.zo... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/section.rb | app/models/section.rb | class Section < ApplicationRecord
belongs_to :course
has_many :lessons, -> { order(:position) }, inverse_of: :section, dependent: :destroy
validates :position, presence: true
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/user_provider.rb | app/models/user_provider.rb | class UserProvider < ApplicationRecord
belongs_to :user
def self.find_user(auth)
OmniauthProviders::Finder.find(auth).user
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/point.rb | app/models/point.rb | class Point < ApplicationRecord
LOWEST_ALLOWED_INCREMENT = 1
MAX_ALLOWED_INCREMENT = 5
validates :discord_id, presence: true, uniqueness: true
def increment_points_by(value)
return unless value.between?(LOWEST_ALLOWED_INCREMENT, MAX_ALLOWED_INCREMENT)
update!(points: self.points += value)
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/success_story.rb | app/models/success_story.rb | class SuccessStory < ApplicationRecord
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/flag.rb | app/models/flag.rb | class Flag < ApplicationRecord
Reason = Data.define(:name, :description, :value)
REASONS = [
{ name: :broken, description: 'Link does not work', value: 10 },
{ name: :insecure, description: 'Link is not secure or safe', value: 20 },
{ name: :spam, description: 'Spam or misleading', value: 30 },
{ n... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/lesson_completion.rb | app/models/lesson_completion.rb | class LessonCompletion < ApplicationRecord
belongs_to :user
belongs_to :lesson
belongs_to :course, optional: true
belongs_to :path, optional: true
validates :user_id, uniqueness: { scope: :lesson_id }
scope :completed_on, ->(date) { where(created_at: date.all_day) }
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/application_record.rb | app/models/application_record.rb | class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
def self.ransackable_attributes(_ = nil)
authorizable_ransackable_attributes
end
def self.ransackable_associations(_ = nil)
authorizable_ransackable_associations
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/lesson_preview.rb | app/models/lesson_preview.rb | class LessonPreview < ApplicationRecord
validates :content, presence: true, length: { maximum: 70_000 }
scope :expired, -> { where(created_at: ..1.month.ago.end_of_day) }
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/admin_user.rb | app/models/admin_user.rb | class AdminUser < ApplicationRecord
include TwoFactorAuthenticatable
include PublicActivity::Common
include AASM
enum :status, %w[pending activated deactivated pending_reactivation].index_by(&:itself)
enum :role, %w[moderator maintainer core].index_by(&:itself)
devise :two_factor_authenticatable
devise ... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/like.rb | app/models/like.rb | class Like < ApplicationRecord
belongs_to :user
belongs_to :likeable, polymorphic: true, counter_cache: true
validates :user_id, uniqueness: { scope: %i[likeable_id likeable_type] }
validates :likeable_type, presence: true
scope :liked_on, ->(date) { where(created_at: date.all_day) }
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/interview_concept.rb | app/models/interview_concept.rb | class InterviewConcept < ApplicationRecord
has_many :interview_survey_concepts, dependent: :destroy
validates :name, presence: true
validates :name, length: { minimum: 2, maximum: 25 }
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/course.rb | app/models/course.rb | class Course < ApplicationRecord
extend FriendlyId
friendly_id :title, use: %i[scoped slugged history finders], scope: :path
belongs_to :path
has_many :sections, -> { order(:position) }, dependent: :destroy, inverse_of: :course
has_many :lessons, through: :sections
validates :position, presence: true
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/notification.rb | app/models/notification.rb | class Notification < ApplicationRecord
include Noticed::Model
belongs_to :recipient, polymorphic: true
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/announcement.rb | app/models/announcement.rb | class Announcement < ApplicationRecord
include PublicActivity::Common
belongs_to :created_by, class_name: 'AdminUser', inverse_of: :announcements
validates :message, presence: true
validates :message, length: { maximum: 100 }
validates :expires_at, presence: true
validates :learn_more_url, url: true, allo... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/user.rb | app/models/user.rb | class User < ApplicationRecord
include PgSearch::Model
before_create :enroll_in_foundations
devise :database_authenticatable, :registerable, :recoverable,
:rememberable, :trackable, :validatable,
:omniauthable, omniauth_providers: %i[github google]
validates :email, uniqueness: true, format... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/omniauth_providers/finder.rb | app/models/omniauth_providers/finder.rb | module OmniauthProviders
class Finder
attr_reader :auth
private :auth
def initialize(auth)
@auth = auth
end
def self.find(auth)
new(auth).find
end
def find
return omniauth_provider if omniauth_provider.present?
new_user_provider
end
private
def omn... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/omniauth_providers/builder.rb | app/models/omniauth_providers/builder.rb | module OmniauthProviders
class Builder
def initialize(auth, user)
@auth = auth
@user = user
end
def build
UserProvider.create!(provider_attributes)
end
private
attr_reader :auth, :user
def provider_attributes
{
provider: auth.provider,
uid: auth.... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/concerns/likeable.rb | app/models/concerns/likeable.rb | module Likeable
extend ActiveSupport::Concern
included do
has_many :likes, as: :likeable, dependent: :destroy
attribute :liked, :boolean, default: false
end
def liked_by?(user)
likes.exists?(user:)
end
def like(user)
likes.find_or_create_by(user:)
liked!
end
def unlike(user)
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/concerns/two_factor_authenticatable.rb | app/models/concerns/two_factor_authenticatable.rb | module TwoFactorAuthenticatable
extend ActiveSupport::Concern
def generate_two_factor_secret_if_missing!
return if otp_secret.present?
update!(otp_secret: self.class.generate_otp_secret)
end
def two_factor_qr_code_uri
otp_provisioning_uri(email, issuer: 'The Odin Project')
end
def enable_two... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/concerns/materialized_view.rb | app/models/concerns/materialized_view.rb | module MaterializedView
extend ActiveSupport::Concern
class_methods do
def refresh
Scenic.database.refresh_materialized_view(table_name, concurrently: false, cascade: false)
end
end
def readonly?
true
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/flags/action_factory.rb | app/models/flags/action_factory.rb | class Flags::ActionFactory
def initialize(action)
@action = action.to_sym
end
def self.for(action)
new(action).action
end
def action
{
dismiss: Flags::Actions::Dismiss,
ban: Flags::Actions::Ban,
removed_project_submission: Flags::Actions::RemoveProjectSubmission,
notified... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/flags/action.rb | app/models/flags/action.rb | Flags::Action = Data.define(:value, :name, :description, :past_tense) do
include Enumerable
def self.all
I18n.t('flag_actions').map { |action| new(**action) }
end
def self.each(&)
all.each(&)
end
def self.for(value)
all.find { |action| action.value == value }
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/flags/actions/null_action.rb | app/models/flags/actions/null_action.rb | class Flags::Actions::NullAction < Flags::Actions::Base
def perform
Result.new(success: false, message: 'Failed: Unknown action')
end
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/flags/actions/notify_user.rb | app/models/flags/actions/notify_user.rb | class Flags::Actions::NotifyUser < Flags::Actions::Base
def perform # rubocop:disable Metrics/AbcSize
ActiveRecord::Base.transaction do
flag.project_submission.update!(discard_at: 7.days.from_now)
flag.resolve(action_taken: :notified_user, resolved_by: admin_user)
end
if flag.resolved?
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/flags/actions/remove_project_submission.rb | app/models/flags/actions/remove_project_submission.rb | class Flags::Actions::RemoveProjectSubmission < Flags::Actions::Base
def perform
ActiveRecord::Base.transaction do
flag.project_submission.discard
flag.resolve(action_taken: :removed_project_submission, resolved_by: admin_user)
end
if flag.resolved?
Result.new(success: true, message: '... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/flags/actions/base.rb | app/models/flags/actions/base.rb | class Flags::Actions::Base
def initialize(admin_user:, flag:)
@admin_user = admin_user
@flag = flag
end
def self.perform(**)
new(**).perform
end
def perform
raise NotImplementedError
end
private
attr_reader :admin_user, :flag
class Result
attr_reader :message
def initiali... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/flags/actions/dismiss.rb | app/models/flags/actions/dismiss.rb | class Flags::Actions::Dismiss < Flags::Actions::Base
def perform
flag.resolve(action_taken: :dismiss, resolved_by: admin_user)
if flag.resolved?
Result.new(success: true, message: 'Flag dismissed')
else
Result.new(success: false, message: flag.errors.full_messages.join(', '))
end
end
en... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/flags/actions/ban.rb | app/models/flags/actions/ban.rb | class Flags::Actions::Ban < Flags::Actions::Base
def perform
flag.project_submission_owner.ban!
flag.resolve(action_taken: :ban, resolved_by: admin_user)
if flag.resolved?
Result.new(success: true, message: 'Project submission owner has been banned')
else
Result.new(success: false, messag... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/github/lesson_content_importer.rb | app/models/github/lesson_content_importer.rb | class Github::LessonContentImporter
def initialize(lesson)
@lesson = lesson
@content = lesson.content || lesson.build_content
end
def self.for(lesson)
new(lesson).import
end
def self.import_all
total = Lesson.count
Rails.logger.info 'Importing lesson content...'
Lesson.all.each_wit... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/github/push_event.rb | app/models/github/push_event.rb | class Github::PushEvent
def initialize(payload)
@payload = payload
end
def merged_to_main?
payload[:ref] == 'refs/heads/main'
end
def modified_urls
payload[:head_commit][:modified].map { |url| "/#{url}" }
end
private
attr_reader :payload
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/reports/period.rb | app/models/reports/period.rb | class Reports::Period
include Comparable
VALID_PERIODS = %w[day month year].freeze
attr_reader :name
def initialize(name)
@name = name
end
def self.all
VALID_PERIODS.map { |period| new(period) }
end
def self.find(value)
all.find { |period| period == new(value) }
end
def <=>(other)
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/reports/path_lesson_completions_day_stat.rb | app/models/reports/path_lesson_completions_day_stat.rb | class Reports::PathLessonCompletionsDayStat < ApplicationRecord
include MaterializedView
belongs_to :path
belongs_to :course
scope :for_date_range, ->(start_date, end_date) { where(date: start_date..end_date) }
scope :group_by_lesson, lambda {
group(:lesson_title, :lesson_id, :lesson_position, :course_... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/reports/all_lesson_completions_day_stat.rb | app/models/reports/all_lesson_completions_day_stat.rb | class Reports::AllLessonCompletionsDayStat < ApplicationRecord
include MaterializedView
scope :for_date_range, ->(start_date, end_date) { where(date: start_date..end_date) }
scope :group_by_period, lambda { |period|
group("DATE_TRUNC('#{period}', date)")
.order(Arel.sql("DATE_TRUNC('#{period}', date) ... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/reports/user_sign_ups_day_stat.rb | app/models/reports/user_sign_ups_day_stat.rb | class Reports::UserSignUpsDayStat < ApplicationRecord
include MaterializedView
scope :for_date_range, ->(start_date, end_date) { where(date: start_date..end_date) }
scope :group_by_period, lambda { |period|
group("DATE_TRUNC('#{period}', date)")
.order(Arel.sql("DATE_TRUNC('#{period}', date) ASC"))
... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/users/theme.rb | app/models/users/theme.rb | module Users
class Theme
include Comparable
DEFAULT_THEMES = [
%w[light moon],
%w[dark sun]
].freeze
def self.default_themes
DEFAULT_THEMES.map { |name, icon| new(name:, icon:) }
end
def self.exists?(theme)
default_themes.map(&:name).include?(theme)
end
def ... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/models/notifications/flag_notification.rb | app/models/notifications/flag_notification.rb | class Notifications::FlagNotification < Noticed::Base
deliver_by :database, format: :to_database
def to_database
{
type: self.class.name,
params: params[:flag],
url: params[:url],
message: params[:message],
title: params[:title]
}
end
param :flag, :url, :message, :title
e... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/builders/tailwind_form_builder.rb | app/builders/tailwind_form_builder.rb | class TailwindFormBuilder < ActionView::Helpers::FormBuilder
# rubocop:disable Layout/LineLength
TEXT_FIELD_CLASSES = ClassVariants.build(
base: 'block w-full border rounded-md py-2 px-3 focus:outline-hidden dark:bg-gray-700/50 dark:border-gray-500 dark:text-gray-300 dark:placeholder-gray-400 dark:focus:ring-2 ... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/app/mailers/application_mailer.rb | app/mailers/application_mailer.rb | class ApplicationMailer < ActionMailer::Base
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/db/seeds.rb | db/seeds.rb | # 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... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/db/schema.rb | db/schema.rb | # 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... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/db/seeds/test_users_and_admins.rb | db/seeds/test_users_and_admins.rb | 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... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/db/seeds/feature_flags.rb | db/seeds/feature_flags.rb | 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... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/db/seeds/success_stories.rb | db/seeds/success_stories.rb | 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... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/db/seeds/test_project_submissions.rb | db/seeds/test_project_submissions.rb | 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... | ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
TheOdinProject/theodinproject | https://github.com/TheOdinProject/theodinproject/blob/bc97027b6e48d5197a4e88f4b05b9c4341c19b3a/db/seeds/update_course_counts.rb | db/seeds/update_course_counts.rb | Course.find_each do |course|
course.update(
projects_count: course.lessons.where(is_project: true).count,
lessons_count: course.lessons.where(is_project: false).count
)
end
| ruby | MIT | bc97027b6e48d5197a4e88f4b05b9c4341c19b3a | 2026-01-04T15:46:55.521218Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.