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

ruby on rails app #31

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
wip
SebouChu committed May 22, 2023

Verified

This commit was signed with the committer’s verified signature.
SebouChu Sébastien Gaya
commit d73d3014ed300ca589756ec27b549ad25e52a39b
1 change: 0 additions & 1 deletion service/ruby-on-rails/Gemfile
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ source "https://rubygems.org"
ruby "3.2.2"

gem "bootsnap", require: false
gem "jbuilder"
gem "rails", "~> 7.0.4", ">= 7.0.4.3"
gem "pg", "~> 1.1"
gem "puma", "~> 5.0"
4 changes: 0 additions & 4 deletions service/ruby-on-rails/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -83,9 +83,6 @@ GEM
io-console (0.6.0)
irb (1.6.4)
reline (>= 0.3.0)
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
loofah (2.21.3)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
@@ -162,7 +159,6 @@ PLATFORMS
DEPENDENCIES
bootsnap
debug
jbuilder
pg (~> 1.1)
puma (~> 5.0)
rails (~> 7.0.4, >= 7.0.4.3)
19 changes: 19 additions & 0 deletions service/ruby-on-rails/app/controllers/lists_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

class ListsController < ApplicationController
before_action :load_account

def create
@list = @account.lists.new(name: params[:name])
if @list.save
render json: @list, status: :created
else
render json: @list.errors, status: :unprocessable_entity
end
end

private

def load_account
@account = Account.find(params[:account_id])
end
end
19 changes: 19 additions & 0 deletions service/ruby-on-rails/app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

class TasksController < ApplicationController
before_action :load_list

def create
@task = @list.tasks.new(name: params[:name], description: params[:description])
if @task.save
render json: @task, status: :created
else
render json: @task.errors, status: :unprocessable_entity
end
end

private

def load_list
@list = List.find(params[:list_id])
end
end
2 changes: 1 addition & 1 deletion service/ruby-on-rails/config/routes.rb
Original file line number Diff line number Diff line change
@@ -5,6 +5,6 @@
post "/api/accounts/:account_id/lists" => "lists#create"
post "/api/lists/:list_id/tasks" => "tasks#create"

get "/api/accounts/:account_id/:lists" => "lists#index"
get "/api/accounts/:account_id/lists" => "lists#index"
get "/api/stats" => "stats#index"
end
4 changes: 0 additions & 4 deletions service/ruby-on-rails/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
services:
runner:
image: jdrouet/eco-benchmark:runner-default
platform: linux/amd64
build: ../../runner
command:
- run
@@ -17,7 +16,6 @@ services:

service:
image: jdrouet/eco-benchmark:service-ruby-on-rails-default
platform: linux/amd64
build: .
depends_on:
- database
@@ -28,7 +26,6 @@ services:

database:
image: jdrouet/eco-benchmark:database-default
platform: linux/amd64
build: ../../migrations
environment:
- POSTGRES_PASSWORD=mysecretpassword
@@ -41,7 +38,6 @@ services:

validator:
image: grafana/k6
platform: linux/amd64
build: ../../validator
command:
- run