feat: added owner to buubles

Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
Louis Vallat 2023-12-31 18:11:17 +01:00
parent a1d2fb9444
commit 11f5929a1a
No known key found for this signature in database
GPG Key ID: 0C87282F76E61283
11 changed files with 352 additions and 9 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

293
.idea/debt-manager.iml Normal file
View File

@ -0,0 +1,293 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="RUBY_MODULE" version="4">
<component name="FacetManager">
<facet type="RailsFacetType" name="Ruby on Rails">
<configuration>
<RAILS_FACET_CONFIG_ID NAME="RAILS_FACET_SUPPORT_REMOVED" VALUE="false" />
<RAILS_FACET_CONFIG_ID NAME="RAILS_TESTS_SOURCES_PATCHED" VALUE="true" />
<RAILS_FACET_CONFIG_ID NAME="RAILS_FACET_APPLICATION_ROOT" VALUE="$MODULE_DIR$" />
</configuration>
</facet>
</component>
<component name="ModuleRunConfigurationManager">
<shared />
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.bundle" />
<excludeFolder url="file://$MODULE_DIR$/components" />
<excludeFolder url="file://$MODULE_DIR$/log" />
<excludeFolder url="file://$MODULE_DIR$/public/packs" />
<excludeFolder url="file://$MODULE_DIR$/public/system" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
<excludeFolder url="file://$MODULE_DIR$/vendor/bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/cache" />
</content>
<orderEntry type="jdk" jdkName="rbenv: 3.2.2" jdkType="RUBY_SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="actioncable (v7.0.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionmailbox (v7.0.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionmailer (v7.0.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionpack (v7.0.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actiontext (v7.0.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionview (v7.0.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activejob (v7.0.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activemodel (v7.0.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activerecord (v7.0.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activestorage (v7.0.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activesupport (v7.0.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.5, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="annotate (v3.2.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bcrypt (v3.1.19, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bindex (v0.8.1, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bootsnap (v1.16.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="builder (v3.2.4, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.4.15, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="capybara (v3.39.2, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.2.2, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="crass (v1.0.6, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="cssbundling-rails (v1.2.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="debug (v1.8.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="devise (v4.9.3, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="erubi (v1.12.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="globalid (v1.2.1, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="i18n (v1.14.1, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="io-console (v0.6.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="irb (v1.8.1, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jbuilder (v2.11.5, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jsbundling-rails (v1.1.2, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="loofah (v2.21.3, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mail (v2.8.1, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="marcel (v1.0.2, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="matrix (v0.4.2, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="method_source (v1.0.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mini_mime (v1.1.5, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.20.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="msgpack (v1.7.2, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="net-imap (v0.3.7, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="net-pop (v0.1.2, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="net-smtp (v0.3.3, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="nio4r (v2.5.9, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.15.4, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="orm_adapter (v0.5.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="pg (v1.5.4, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="psych (v5.1.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="public_suffix (v5.0.3, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="puma (v5.6.7, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="racc (v1.7.1, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack (v2.2.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack-test (v2.1.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails (v7.0.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v2.2.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.6.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="railties (v7.0.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rdoc (v6.5.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.8.1, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="reline (v0.3.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="responders (v3.1.1, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.6, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rubyzip (v2.3.2, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="selenium-webdriver (v4.12.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="sprockets (v4.2.1, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="sprockets-rails (v3.4.2, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="stimulus-rails (v1.2.2, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="stringio (v3.0.8, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="thor (v1.2.2, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="timeout (v0.4.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="turbo-rails (v1.4.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.6, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="warden (v1.2.9, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="web-console (v4.2.1, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="websocket (v1.2.9, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="websocket-driver (v0.7.6, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="websocket-extensions (v0.1.5, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="xpath (v3.2.0, rbenv: 3.2.2) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.6.11, rbenv: 3.2.2) [gem]" level="application" />
</component>
<component name="RModuleSettingsStorage">
<LOAD_PATH number="0" />
<I18N_FOLDERS number="1" string0="$MODULE_DIR$/config/locales" />
</component>
<component name="RailsGeneratorsCache">
<option name="generators">
<list>
<option value="active_record:application_record" />
<option value="active_record:devise" />
<option value="active_record:multi_db" />
<option value="annotate:install" />
<option value="application_record" />
<option value="benchmark" />
<option value="channel" />
<option value="controller" />
<option value="devise" />
<option value="devise:controllers" />
<option value="devise:install" />
<option value="devise:views" />
<option value="generator" />
<option value="helper" />
<option value="integration_test" />
<option value="jbuilder" />
<option value="job" />
<option value="mailbox" />
<option value="mailer" />
<option value="migration" />
<option value="model" />
<option value="mongoid:devise" />
<option value="resource" />
<option value="responders:install" />
<option value="responders_controller" />
<option value="scaffold" />
<option value="scaffold_controller" />
<option value="stimulus" />
<option value="system_test" />
<option value="task" />
<option value="test_unit:channel" />
<option value="test_unit:generator" />
<option value="test_unit:install" />
<option value="test_unit:mailbox" />
<option value="test_unit:plugin" />
</list>
</option>
<option name="myGenerators">
<list>
<option value="active_record:application_record" />
<option value="active_record:devise" />
<option value="active_record:multi_db" />
<option value="annotate:install" />
<option value="application_record" />
<option value="benchmark" />
<option value="channel" />
<option value="controller" />
<option value="devise" />
<option value="devise:controllers" />
<option value="devise:install" />
<option value="devise:views" />
<option value="generator" />
<option value="helper" />
<option value="integration_test" />
<option value="jbuilder" />
<option value="job" />
<option value="mailbox" />
<option value="mailer" />
<option value="migration" />
<option value="model" />
<option value="mongoid:devise" />
<option value="resource" />
<option value="responders:install" />
<option value="responders_controller" />
<option value="scaffold" />
<option value="scaffold_controller" />
<option value="stimulus" />
<option value="system_test" />
<option value="task" />
<option value="test_unit:channel" />
<option value="test_unit:generator" />
<option value="test_unit:install" />
<option value="test_unit:mailbox" />
<option value="test_unit:plugin" />
</list>
</option>
</component>
<component name="RailsPaths" isManagedAutomatically="true">
<entry key="app">
<value>file://$MODULE_DIR$/app</value>
</entry>
<entry key="app/assets">
<value>file://$MODULE_DIR$/app/assets</value>
</entry>
<entry key="app/channels">
<value>file://$MODULE_DIR$/app/channels</value>
</entry>
<entry key="app/controllers">
<value>file://$MODULE_DIR$/app/controllers</value>
</entry>
<entry key="app/helpers">
<value>file://$MODULE_DIR$/app/helpers</value>
</entry>
<entry key="app/mailers">
<value>file://$MODULE_DIR$/app/mailers</value>
</entry>
<entry key="app/models">
<value>file://$MODULE_DIR$/app/models</value>
</entry>
<entry key="app/views">
<value>file://$MODULE_DIR$/app/views</value>
</entry>
<entry key="config">
<value>file://$MODULE_DIR$/config</value>
</entry>
<entry key="config/cable">
<value>file://$MODULE_DIR$/config/cable.yml</value>
</entry>
<entry key="config/database">
<value>file://$MODULE_DIR$/config/database.yml</value>
</entry>
<entry key="config/environment">
<value>file://$MODULE_DIR$/config/environment.rb</value>
</entry>
<entry key="config/environments">
<value>file://$MODULE_DIR$/config/environments</value>
</entry>
<entry key="config/initializers">
<value>file://$MODULE_DIR$/config/initializers</value>
</entry>
<entry key="config/locales">
<value>file://$MODULE_DIR$/config/locales</value>
</entry>
<entry key="config/routes">
<value>file://$MODULE_DIR$/config/routes</value>
</entry>
<entry key="config/routes.rb">
<value>file://$MODULE_DIR$/config/routes.rb</value>
</entry>
<entry key="config/secrets">
<value>file://$MODULE_DIR$/config</value>
</entry>
<entry key="db">
<value>file://$MODULE_DIR$/db</value>
</entry>
<entry key="db/migrate">
<value>file://$MODULE_DIR$/db/migrate</value>
</entry>
<entry key="db/seeds.rb">
<value>file://$MODULE_DIR$/db/seeds.rb</value>
</entry>
<entry key="lib">
<value>file://$MODULE_DIR$/lib</value>
</entry>
<entry key="lib/assets">
<value>file://$MODULE_DIR$/lib/assets</value>
</entry>
<entry key="lib/tasks">
<value>file://$MODULE_DIR$/lib/tasks</value>
</entry>
<entry key="lib/templates">
<value>file://$MODULE_DIR$/lib/templates</value>
</entry>
<entry key="log">
<value>file://$MODULE_DIR$/log/development.log</value>
</entry>
<entry key="public">
<value>file://$MODULE_DIR$/public</value>
</entry>
<entry key="public/javascripts">
<value>file://$MODULE_DIR$/public/javascripts</value>
</entry>
<entry key="public/stylesheets">
<value>file://$MODULE_DIR$/public/stylesheets</value>
</entry>
<entry key="tmp">
<value>file://$MODULE_DIR$/tmp</value>
</entry>
<entry key="vendor">
<value>file://$MODULE_DIR$/vendor</value>
</entry>
<entry key="vendor/assets">
<value>file://$MODULE_DIR$/vendor/assets</value>
</entry>
</component>
</module>

4
.idea/misc.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="ruby-3.0.4-p208" project-jdk-type="RUBY_SDK" />
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/debt-manager.iml" filepath="$PROJECT_DIR$/.idea/debt-manager.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -46,7 +46,7 @@ class BubblesController < ApplicationController
private private
def allowed_params def allowed_params
params.require(:bubble).permit(:name, :description, :color) params.require(:bubble).permit(:name, :description, :color, :owner_id)
end end
end end

View File

@ -8,7 +8,17 @@
# name :string not null # name :string not null
# created_at :datetime not null # created_at :datetime not null
# updated_at :datetime not null # updated_at :datetime not null
# owner_id :uuid not null
#
# Indexes
#
# index_bubbles_on_owner_id (owner_id)
#
# Foreign Keys
#
# fk_rails_... (owner_id => users.id)
# #
class Bubble < ApplicationRecord class Bubble < ApplicationRecord
validates :name, presence: true, allow_blank: false validates :name, presence: true, allow_blank: false
belongs_to :owner, class_name: "User"
end end

View File

@ -21,4 +21,6 @@ class User < ApplicationRecord
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable, devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable :recoverable, :rememberable, :validatable
has_many :bubbles, foreign_key: :owner_id
end end

View File

@ -15,6 +15,10 @@
<%= f.color_field :color %> <%= f.color_field :color %>
</div> </div>
<div>
<%= f.label :owner_id, "Administrateur" %>
<%= f.select :owner_id, User.all.collect {|u| [ u.email, u.id ] }, selected: bubble.owner_id || current_user.id %>
</div>
<%= f.submit "Sauvegarder" %> <%= f.submit "Sauvegarder" %>

View File

@ -0,0 +1,5 @@
class AddOwnerToBubbles < ActiveRecord::Migration[7.0]
def change
add_reference(:bubbles, :owner, type: :uuid, foreign_key: { to_table: :users }, null: false)
end
end

5
db/schema.rb generated
View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2023_11_01_172623) do ActiveRecord::Schema[7.0].define(version: 2023_12_10_091848) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto" enable_extension "pgcrypto"
enable_extension "plpgsql" enable_extension "plpgsql"
@ -21,6 +21,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_01_172623) do
t.string "color", default: "#0000ff", null: false t.string "color", default: "#0000ff", null: false
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.uuid "owner_id", null: false
t.index ["owner_id"], name: "index_bubbles_on_owner_id"
end end
create_table "users", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| create_table "users", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
@ -35,4 +37,5 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_01_172623) do
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end end
add_foreign_key "bubbles", "users", column: "owner_id"
end end