Add projects
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled

This commit is contained in:
2025-10-27 12:18:14 +01:00
parent 6776729eab
commit 0dc4dd623d
11 changed files with 61 additions and 1 deletions

View File

@@ -0,0 +1,10 @@
class ProjectsController < ApplicationController
def index
@projects = Project.all
end
def show
@project = Project.find(params[:id])
end
end

View File

@@ -0,0 +1,2 @@
module ProjectsHelper
end

2
app/models/project.rb Normal file
View File

@@ -0,0 +1,2 @@
class Project < ApplicationRecord
end

View File

@@ -0,0 +1,5 @@
<h1>Projects</h1>
<% @projects.each do |project| %>
<li><%= link_to project.name, project_path(project) %></li>
<% end %>

View File

@@ -0,0 +1,2 @@
<h1><%= @project.name %></h1>
<%= link_to "Back", projects_path %>

View File

@@ -1,5 +1,8 @@
Rails.application.routes.draw do
resources :todos
get "/projects", to: "projects#index"
get "/projects/:id", to: "projects#show", as: "project"
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.

View File

@@ -0,0 +1,9 @@
class CreateProjects < ActiveRecord::Migration[8.1]
def change
create_table :projects do |t|
t.string :name
t.timestamps
end
end
end

8
db/schema.rb generated
View File

@@ -10,7 +10,13 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.1].define(version: 2025_10_27_091014) do
ActiveRecord::Schema[8.1].define(version: 2025_10_27_095143) do
create_table "projects", force: :cascade do |t|
t.datetime "created_at", null: false
t.string "name"
t.datetime "updated_at", null: false
end
create_table "todos", force: :cascade do |t|
t.datetime "created_at", null: false
t.text "description"

View File

@@ -0,0 +1,7 @@
require "test_helper"
class ProjectsControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end

7
test/fixtures/projects.yml vendored Normal file
View File

@@ -0,0 +1,7 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
two:
name: MyString

View File

@@ -0,0 +1,7 @@
require "test_helper"
class ProjectTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end