Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding moral alignment controller #37

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/controllers/moral_alignments_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class MoralAlignmentsController < MetaController
def index
scope = set_scope
where = set_where
@component_list = @component_klass.send('where', where).send(scope).order(created_at: :asc).page params[:page]
end

def component_name
'Moral Alignments'
end

def component_class
'MoralAlignment'.constantize
end
end
2 changes: 2 additions & 0 deletions app/helpers/moral_alignments_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module MoralAlignmentsHelper
end
19 changes: 19 additions & 0 deletions app/models/moral_alignment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# == Schema Information
#
# Table name: moral_alignments
#
# id :bigint not null, primary key
# name :string not null
# description :text
# examples :text
# created_at :datetime not null
# updated_at :datetime not null
#
class MoralAlignment < ApplicationRecord
serialize :examples, coder: YAML

validates :name, presence: true, uniqueness: true
validates :description, presence: true

paginates_per 100
end
12 changes: 12 additions & 0 deletions db/migrate/20240924000253_create_moral_alignments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateMoralAlignments < ActiveRecord::Migration[7.2]
def change
create_table :moral_alignments do |t|
t.string :name, null: false
t.text :description
t.text :examples

t.timestamps
end
add_index :moral_alignments, :name, unique: true # Ensure unique alignment names
end
end
Loading