├── log └── .keep ├── storage └── .keep ├── tmp ├── .keep ├── pids │ └── .keep └── storage │ └── .keep ├── vendor ├── .keep └── javascript │ └── .keep ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── public ├── favicon.ico ├── apple-touch-icon.png ├── apple-touch-icon-precomposed.png ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── test ├── helpers │ └── .keep ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── feature_test.rb │ ├── type_offer_test.rb │ ├── type_property_test.rb │ ├── contact_test.rb │ ├── property_feature_test.rb │ ├── property_test.rb │ └── user_test.rb ├── system │ ├── .keep │ ├── contacts_test.rb │ └── properties_test.rb ├── controllers │ ├── .keep │ ├── pages_controller_test.rb │ ├── contacts_controller_test.rb │ └── properties_controller_test.rb ├── integration │ └── .keep ├── fixtures │ ├── files │ │ └── .keep │ ├── features.yml │ ├── type_offers.yml │ ├── type_properties.yml │ ├── property_features.yml │ ├── contacts.yml │ ├── properties.yml │ └── users.yml ├── application_system_test_case.rb ├── channels │ └── application_cable │ │ └── connection_test.rb └── test_helper.rb ├── .ruby-version ├── app ├── assets │ ├── images │ │ └── .keep │ ├── config │ │ └── manifest.js │ └── stylesheets │ │ └── application.css ├── models │ ├── concerns │ │ └── .keep │ ├── application_record.rb │ ├── type_offer.rb │ ├── type_property.rb │ ├── feature.rb │ ├── property_feature.rb │ ├── contact.rb │ ├── property.rb │ └── user.rb ├── controllers │ ├── concerns │ │ └── .keep │ ├── application_controller.rb │ ├── pages_controller.rb │ ├── registrations_controller.rb │ ├── contacts_controller.rb │ └── properties_controller.rb ├── views │ ├── layouts │ │ ├── mailer.text.erb │ │ ├── mailer.html.erb │ │ └── application.html.erb │ ├── properties │ │ ├── show.json.jbuilder │ │ ├── index.json.jbuilder │ │ ├── new.html.erb │ │ ├── _property.json.jbuilder │ │ ├── edit.html.erb │ │ ├── show.html.erb │ │ ├── index.html.erb │ │ ├── _property.html.erb │ │ └── _form.html.erb │ ├── pages │ │ ├── home.html.erb │ │ └── terms.html.erb │ ├── devise │ │ ├── mailer │ │ │ ├── password_change.html.erb │ │ │ ├── confirmation_instructions.html.erb │ │ │ ├── unlock_instructions.html.erb │ │ │ ├── email_changed.html.erb │ │ │ └── reset_password_instructions.html.erb │ │ ├── shared │ │ │ ├── _error_messages.html.erb │ │ │ └── _links.html.erb │ │ ├── unlocks │ │ │ └── new.html.erb │ │ ├── passwords │ │ │ ├── new.html.erb │ │ │ └── edit.html.erb │ │ ├── confirmations │ │ │ └── new.html.erb │ │ ├── sessions │ │ │ └── new.html.erb │ │ └── registrations │ │ │ ├── new.html.erb │ │ │ └── edit.html.erb │ ├── contacts │ │ ├── new.html.erb │ │ └── _form.html.erb │ └── shared │ │ └── _navbar.html.erb ├── helpers │ ├── pages_helper.rb │ ├── contacts_helper.rb │ ├── properties_helper.rb │ └── application_helper.rb ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── mailers │ └── application_mailer.rb ├── javascript │ ├── application.js │ └── controllers │ │ ├── hello_controller.js │ │ ├── application.js │ │ └── index.js └── jobs │ └── application_job.rb ├── config ├── initializers │ ├── pagy.rb │ ├── filter_parameter_logging.rb │ ├── permissions_policy.rb │ ├── assets.rb │ ├── inflections.rb │ ├── content_security_policy.rb │ └── devise.rb ├── environment.rb ├── boot.rb ├── cable.yml ├── importmap.rb ├── credentials.yml.enc ├── routes.rb ├── locales │ ├── en.yml │ └── devise.en.yml ├── application.rb ├── storage.yml ├── puma.rb ├── environments │ ├── test.rb │ ├── development.rb │ └── production.rb └── database.yml ├── db ├── seeds │ ├── csv │ │ ├── typeOffers.csv │ │ ├── typeProperties.csv │ │ └── features.csv │ └── rb │ │ ├── propertyFeatures.rb │ │ ├── contacts.rb │ │ ├── users.rb │ │ └── properties.rb ├── migrate │ ├── 20231007141821_create_features.rb │ ├── 20231007141223_create_type_offers.rb │ ├── 20231007140630_create_type_properties.rb │ ├── 20231007123938_create_contacts.rb │ ├── 20231007145618_create_property_features.rb │ ├── 20231007142957_create_properties.rb │ └── 20231007133131_devise_create_users.rb ├── seeds.rb └── schema.rb ├── bin ├── rake ├── importmap ├── rails ├── docker-entrypoint ├── setup └── bundle ├── config.ru ├── Rakefile ├── .gitattributes ├── .dockerignore ├── .gitignore ├── Dockerfile ├── Gemfile ├── README.md └── Gemfile.lock /log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /storage/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/system/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tmp/pids/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tmp/storage/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 3.2.2 2 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/javascript/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/files/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /app/helpers/pages_helper.rb: -------------------------------------------------------------------------------- 1 | module PagesHelper 2 | end 3 | -------------------------------------------------------------------------------- /config/initializers/pagy.rb: -------------------------------------------------------------------------------- 1 | require 'pagy/extras/bootstrap' -------------------------------------------------------------------------------- /app/helpers/contacts_helper.rb: -------------------------------------------------------------------------------- 1 | module ContactsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/properties_helper.rb: -------------------------------------------------------------------------------- 1 | module PropertiesHelper 2 | end 3 | -------------------------------------------------------------------------------- /db/seeds/csv/typeOffers.csv: -------------------------------------------------------------------------------- 1 | type_offer_id,name 2 | 1,Venta 3 | 2,Alquiler 4 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | include Pagy::Frontend 3 | end 4 | -------------------------------------------------------------------------------- /app/views/properties/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.partial! "properties/property", property: @property 2 | -------------------------------------------------------------------------------- /app/views/pages/home.html.erb: -------------------------------------------------------------------------------- 1 |

Pages#home

2 |

Find me in app/views/pages/home.html.erb

3 | -------------------------------------------------------------------------------- /app/views/pages/terms.html.erb: -------------------------------------------------------------------------------- 1 |

Pages#terms

2 |

Find me in app/views/pages/terms.html.erb

3 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | primary_abstract_class 3 | end 4 | -------------------------------------------------------------------------------- /app/views/properties/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array! @properties, partial: "properties/property", as: :property 2 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative "../config/boot" 3 | require "rake" 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /bin/importmap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require_relative "../config/application" 4 | require "importmap/commands" 5 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /db/seeds/csv/typeProperties.csv: -------------------------------------------------------------------------------- 1 | type_property_id,name 2 | 1,Apartamento 3 | 2,Casa 4 | 3,Finca 5 | 4,Habitacion 6 | 5,Cabaña 7 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | include Pagy::Backend 3 | end 4 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/pages_controller.rb: -------------------------------------------------------------------------------- 1 | class PagesController < ApplicationController 2 | def home 3 | end 4 | 5 | def terms 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: "from@example.com" 3 | layout "mailer" 4 | end 5 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path("../config/application", __dir__) 3 | require_relative "../config/boot" 4 | require "rails/commands" 5 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative "application" 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /app/views/devise/mailer/password_change.html.erb: -------------------------------------------------------------------------------- 1 |

Hello <%= @resource.email %>!

2 | 3 |

We're contacting you to notify you that your password has been changed.

4 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../stylesheets .css 3 | //= link_tree ../../javascript .js 4 | //= link_tree ../../../vendor/javascript .js 5 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative "config/environment" 4 | 5 | run Rails.application 6 | Rails.application.load_server 7 | -------------------------------------------------------------------------------- /db/seeds/csv/features.csv: -------------------------------------------------------------------------------- 1 | feature_id,name 2 | 1,Sala 3 | 2,Comedor 4 | 3,Cocina 5 | 4,Vestier 6 | 5,Closets 7 | 6,Despensa 8 | 7,Lavanderia 9 | 8,Oficina 10 | 9,Bodega 11 | 10,Atico -------------------------------------------------------------------------------- /app/javascript/application.js: -------------------------------------------------------------------------------- 1 | // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails 2 | import "@hotwired/turbo-rails" 3 | import "controllers" 4 | -------------------------------------------------------------------------------- /app/views/contacts/new.html.erb: -------------------------------------------------------------------------------- 1 |

New contact

2 | 3 | <%= render "form", contact: @contact %> 4 | 5 |
6 | 7 |
8 | <%= link_to "Back to contacts", contacts_path %> 9 |
10 | -------------------------------------------------------------------------------- /test/application_system_test_case.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class ApplicationSystemTestCase < ActionDispatch::SystemTestCase 4 | driven_by :selenium, using: :chrome, screen_size: [1400, 1400] 5 | end 6 | -------------------------------------------------------------------------------- /app/views/properties/new.html.erb: -------------------------------------------------------------------------------- 1 |

New property

2 | 3 | <%= render "form", property: @property %> 4 | 5 |
6 | 7 |
8 | <%= link_to "Back to properties", properties_path %> 9 |
10 | -------------------------------------------------------------------------------- /app/views/properties/_property.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! property, :id, :user_id, :type_offer_id, :type_property_id, :description, :area, :price, :created_at, :updated_at 2 | json.url property_url(property, format: :json) 3 | -------------------------------------------------------------------------------- /app/javascript/controllers/hello_controller.js: -------------------------------------------------------------------------------- 1 | import { Controller } from "@hotwired/stimulus" 2 | 3 | export default class extends Controller { 4 | connect() { 5 | this.element.textContent = "Hello World!" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 2 | 3 | require "bundler/setup" # Set up gems listed in the Gemfile. 4 | require "bootsnap/setup" # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /bin/docker-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # If running the rails server then create or migrate existing database 4 | if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then 5 | ./bin/rails db:prepare 6 | fi 7 | 8 | exec "${@}" 9 | -------------------------------------------------------------------------------- /db/migrate/20231007141821_create_features.rb: -------------------------------------------------------------------------------- 1 | class CreateFeatures < ActiveRecord::Migration[7.1] 2 | def change 3 | create_table :features do |t| 4 | t.string :name 5 | 6 | t.timestamps 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/20231007141223_create_type_offers.rb: -------------------------------------------------------------------------------- 1 | class CreateTypeOffers < ActiveRecord::Migration[7.1] 2 | def change 3 | create_table :type_offers do |t| 4 | t.string :name 5 | 6 | t.timestamps 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative "config/application" 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: test 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: inforcap_house_production 11 | -------------------------------------------------------------------------------- /db/migrate/20231007140630_create_type_properties.rb: -------------------------------------------------------------------------------- 1 | class CreateTypeProperties < ActiveRecord::Migration[7.1] 2 | def change 3 | create_table :type_properties do |t| 4 | t.string :name 5 | 6 | t.timestamps 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /app/views/devise/mailer/confirmation_instructions.html.erb: -------------------------------------------------------------------------------- 1 |

Welcome <%= @email %>!

2 | 3 |

You can confirm your account email through the link below:

4 | 5 |

<%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>

6 | -------------------------------------------------------------------------------- /app/views/properties/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing property

2 | 3 | <%= render "form", property: @property %> 4 | 5 |
6 | 7 |
8 | <%= link_to "Show this property", @property %> | 9 | <%= link_to "Back to properties", properties_path %> 10 |
11 | -------------------------------------------------------------------------------- /db/migrate/20231007123938_create_contacts.rb: -------------------------------------------------------------------------------- 1 | class CreateContacts < ActiveRecord::Migration[7.1] 2 | def change 3 | create_table :contacts do |t| 4 | t.string :name 5 | t.string :email 6 | t.text :message 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/javascript/controllers/application.js: -------------------------------------------------------------------------------- 1 | import { Application } from "@hotwired/stimulus" 2 | 3 | const application = Application.start() 4 | 5 | // Configure Stimulus development experience 6 | application.debug = false 7 | window.Stimulus = application 8 | 9 | export { application } 10 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | # Automatically retry jobs that encountered a deadlock 3 | # retry_on ActiveRecord::Deadlocked 4 | 5 | # Most jobs are safe to ignore if the underlying records are no longer available 6 | # discard_on ActiveJob::DeserializationError 7 | end 8 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/views/devise/mailer/unlock_instructions.html.erb: -------------------------------------------------------------------------------- 1 |

Hello <%= @resource.email %>!

2 | 3 |

Your account has been locked due to an excessive number of unsuccessful sign in attempts.

4 | 5 |

Click the link below to unlock your account:

6 | 7 |

<%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>

8 | -------------------------------------------------------------------------------- /test/fixtures/features.yml: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: features 4 | # 5 | # id :bigint not null, primary key 6 | # name :string 7 | # created_at :datetime not null 8 | # updated_at :datetime not null 9 | # 10 | 11 | one: 12 | name: MyString 13 | 14 | two: 15 | name: MyString 16 | -------------------------------------------------------------------------------- /app/views/properties/show.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 | <%= render @property %> 4 | 5 |
6 | <%= link_to "Edit this property", edit_property_path(@property) %> | 7 | <%= link_to "Back to properties", properties_path %> 8 | 9 | <%= button_to "Destroy this property", @property, method: :delete %> 10 |
11 | -------------------------------------------------------------------------------- /test/fixtures/type_offers.yml: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: type_offers 4 | # 5 | # id :bigint not null, primary key 6 | # name :string 7 | # created_at :datetime not null 8 | # updated_at :datetime not null 9 | # 10 | 11 | one: 12 | name: MyString 13 | 14 | two: 15 | name: MyString 16 | -------------------------------------------------------------------------------- /db/seeds/rb/propertyFeatures.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # rails runner 'load(File.join(Rails.root, "db", "seeds", "rb", "propertyFeatures.rb"))' 4 | puts 'Importing propertyFeatures...' 5 | 6 | 1000.times do 7 | PropertyFeature.create( 8 | property_id: Property.all.sample.id, 9 | feature_id: Feature.all.sample.id, 10 | ) 11 | end 12 | -------------------------------------------------------------------------------- /test/controllers/pages_controller_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class PagesControllerTest < ActionDispatch::IntegrationTest 4 | test "should get home" do 5 | get pages_home_url 6 | assert_response :success 7 | end 8 | 9 | test "should get terms" do 10 | get pages_terms_url 11 | assert_response :success 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/fixtures/type_properties.yml: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: type_properties 4 | # 5 | # id :bigint not null, primary key 6 | # name :string 7 | # created_at :datetime not null 8 | # updated_at :datetime not null 9 | # 10 | 11 | one: 12 | name: MyString 13 | 14 | two: 15 | name: MyString 16 | -------------------------------------------------------------------------------- /db/migrate/20231007145618_create_property_features.rb: -------------------------------------------------------------------------------- 1 | class CreatePropertyFeatures < ActiveRecord::Migration[7.1] 2 | def change 3 | create_table :property_features do |t| 4 | t.references :property, null: false, foreign_key: true 5 | t.references :feature, null: false, foreign_key: true 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /app/views/devise/mailer/email_changed.html.erb: -------------------------------------------------------------------------------- 1 |

Hello <%= @email %>!

2 | 3 | <% if @resource.try(:unconfirmed_email?) %> 4 |

We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.

5 | <% else %> 6 |

We're contacting you to notify you that your email has been changed to <%= @resource.email %>.

7 | <% end %> 8 | -------------------------------------------------------------------------------- /config/importmap.rb: -------------------------------------------------------------------------------- 1 | # Pin npm packages by running ./bin/importmap 2 | 3 | pin "application", preload: true 4 | pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true 5 | pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true 6 | pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true 7 | pin_all_from "app/javascript/controllers", under: "controllers" 8 | -------------------------------------------------------------------------------- /test/channels/application_cable/connection_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | module ApplicationCable 4 | class ConnectionTest < ActionCable::Connection::TestCase 5 | # test "connects with cookies" do 6 | # cookies.signed[:user_id] = 42 7 | # 8 | # connect 9 | # 10 | # assert_equal connection.user_id, "42" 11 | # end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /db/seeds/rb/contacts.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # rails runner 'load(File.join(Rails.root, "db", "seeds", "rb", "contacts.rb"))' 4 | puts 'Importing contacts...' 5 | 6 | 20.times do 7 | Contact.create( 8 | name: Faker::Name.name_with_middle, 9 | email: Faker::Internet.email, 10 | message: Faker::Lorem.paragraph_by_chars(number: 500) 11 | ) 12 | end 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # See https://git-scm.com/docs/gitattributes for more about git attribute files. 2 | 3 | # Mark the database schema as having been generated. 4 | db/schema.rb linguist-generated 5 | 6 | # Mark any vendored files as having been vendored. 7 | vendor/* linguist-vendored 8 | config/credentials/*.yml.enc diff=rails_credentials 9 | config/credentials.yml.enc diff=rails_credentials 10 | -------------------------------------------------------------------------------- /app/models/type_offer.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: type_offers 4 | # 5 | # id :bigint not null, primary key 6 | # name :string 7 | # created_at :datetime not null 8 | # updated_at :datetime not null 9 | # 10 | class TypeOffer < ApplicationRecord 11 | # Validaciones 12 | validates :name, presence: true, uniqueness: true 13 | end 14 | -------------------------------------------------------------------------------- /app/models/type_property.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: type_properties 4 | # 5 | # id :bigint not null, primary key 6 | # name :string 7 | # created_at :datetime not null 8 | # updated_at :datetime not null 9 | # 10 | class TypeProperty < ApplicationRecord 11 | # Validaciones 12 | validates :name, presence: true, uniqueness: true 13 | end 14 | -------------------------------------------------------------------------------- /app/views/properties/index.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | <%= link_to "New property", new_property_path %> 3 | 4 |

Properties

5 | 6 |
7 | <% @properties.each do |property| %> 8 | <%= render property %> 9 |

10 | <%= link_to "Show this property", property %> 11 |

12 | <% end %> 13 |
14 | 15 | <%== pagy_bootstrap_nav(@pagy) %> -------------------------------------------------------------------------------- /test/models/feature_test.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: features 4 | # 5 | # id :bigint not null, primary key 6 | # name :string 7 | # created_at :datetime not null 8 | # updated_at :datetime not null 9 | # 10 | require "test_helper" 11 | 12 | class FeatureTest < ActiveSupport::TestCase 13 | # test "the truth" do 14 | # assert true 15 | # end 16 | end 17 | -------------------------------------------------------------------------------- /test/models/type_offer_test.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: type_offers 4 | # 5 | # id :bigint not null, primary key 6 | # name :string 7 | # created_at :datetime not null 8 | # updated_at :datetime not null 9 | # 10 | require "test_helper" 11 | 12 | class TypeOfferTest < ActiveSupport::TestCase 13 | # test "the truth" do 14 | # assert true 15 | # end 16 | end 17 | -------------------------------------------------------------------------------- /test/models/type_property_test.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: type_properties 4 | # 5 | # id :bigint not null, primary key 6 | # name :string 7 | # created_at :datetime not null 8 | # updated_at :datetime not null 9 | # 10 | require "test_helper" 11 | 12 | class TypePropertyTest < ActiveSupport::TestCase 13 | # test "the truth" do 14 | # assert true 15 | # end 16 | end 17 | -------------------------------------------------------------------------------- /db/seeds/rb/users.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # rails runner 'load(File.join(Rails.root, "db", "seeds", "rb", "users.rb"))' 4 | puts 'Importing users...' 5 | 6 | 20.times do 7 | User.create( 8 | email: Faker::Internet.email, 9 | password: '123456', 10 | password_confirmation: '123456', 11 | name: Faker::Name.name_with_middle, 12 | phone: Faker::PhoneNumber.cell_phone, 13 | role: rand(0..1) 14 | ) 15 | end 16 | -------------------------------------------------------------------------------- /config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | bZj2n4K6ZlydN9hRNYRIopWI5R3NaVTEXtfRap/RMNzUpSoqvkNL+3dulo5gcOb+fro1oesrL8hsFQHpbiDJBoxoYuHhjRC+LzU2oFjAI7CSc0w57yTBCDw16wC3dGd385shgWfVBy/uyvjDnbG7zfKZL20C0FPz/4accQXX1yUqSA7lMUbG5xRkcqY7XQx9zf1hUJdlI91iBWA3aNqpEN9J4+okCciXQEqUQNrtO8lCIWv5E4wTn1BifT7nBK1R7bg7P34ny1agKVgNGpzhicKcjUZJrbsvABUIK/tklkt0NZGjqIYtwTaP/aqJUQf4GKCEhbYoE7ThVnAuZ1YxEBz4KVXTfHLAcJJjCP6P8UIyy6JqsOOG68DNMpRf0vv+oCNq+qcP/ngrHMhSmC3/518XKsI0--bMq5mTHMXjsFkqOC--Uqkygx2HihDjhKM4ArTWCA== -------------------------------------------------------------------------------- /app/views/devise/mailer/reset_password_instructions.html.erb: -------------------------------------------------------------------------------- 1 |

Hello <%= @resource.email %>!

2 | 3 |

Someone has requested a link to change your password. You can do this through the link below.

4 | 5 |

<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>

6 | 7 |

If you didn't request this, please ignore this email.

8 |

Your password won't change until you access the link above and create a new one.

9 | -------------------------------------------------------------------------------- /test/fixtures/property_features.yml: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: property_features 4 | # 5 | # id :bigint not null, primary key 6 | # property_id :bigint not null 7 | # feature_id :bigint not null 8 | # created_at :datetime not null 9 | # updated_at :datetime not null 10 | # 11 | 12 | one: 13 | property: one 14 | feature: one 15 | 16 | two: 17 | property: two 18 | feature: two 19 | -------------------------------------------------------------------------------- /test/models/contact_test.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: contacts 4 | # 5 | # id :bigint not null, primary key 6 | # name :string 7 | # email :string 8 | # message :text 9 | # created_at :datetime not null 10 | # updated_at :datetime not null 11 | # 12 | require "test_helper" 13 | 14 | class ContactTest < ActiveSupport::TestCase 15 | # test "the truth" do 16 | # assert true 17 | # end 18 | end 19 | -------------------------------------------------------------------------------- /test/fixtures/contacts.yml: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: contacts 4 | # 5 | # id :bigint not null, primary key 6 | # name :string 7 | # email :string 8 | # message :text 9 | # created_at :datetime not null 10 | # updated_at :datetime not null 11 | # 12 | 13 | one: 14 | name: MyString 15 | email: MyString 16 | message: MyText 17 | 18 | two: 19 | name: MyString 20 | email: MyString 21 | message: MyText 22 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RAILS_ENV"] ||= "test" 2 | require_relative "../config/environment" 3 | require "rails/test_help" 4 | 5 | module ActiveSupport 6 | class TestCase 7 | # Run tests in parallel with specified workers 8 | parallelize(workers: :number_of_processors) 9 | 10 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 11 | fixtures :all 12 | 13 | # Add more helper methods to be used by all tests here... 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /db/migrate/20231007142957_create_properties.rb: -------------------------------------------------------------------------------- 1 | class CreateProperties < ActiveRecord::Migration[7.1] 2 | def change 3 | create_table :properties do |t| 4 | t.references :user, null: false, foreign_key: true 5 | t.references :type_offer, null: false, foreign_key: true 6 | t.references :type_property, null: false, foreign_key: true 7 | t.text :description 8 | t.integer :area 9 | t.decimal :price 10 | 11 | t.timestamps 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /db/seeds/rb/properties.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # rails runner 'load(File.join(Rails.root, "db", "seeds", "rb", "properties.rb"))' 4 | puts 'Importing properties...' 5 | 6 | 100.times do 7 | Property.create( 8 | user_id: User.all.sample.id, 9 | type_offer_id: TypeOffer.all.sample.id, 10 | type_property_id: rand(1..5), 11 | description: Faker::Lorem.paragraph(sentence_count: 2), 12 | area: rand(50..200), 13 | price: rand(100_000..1_000_000) 14 | ) 15 | end 16 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. 4 | # Use this to limit dissemination of sensitive information. 5 | # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. 6 | Rails.application.config.filter_parameters += [ 7 | :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn 8 | ] 9 | -------------------------------------------------------------------------------- /test/models/property_feature_test.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: property_features 4 | # 5 | # id :bigint not null, primary key 6 | # property_id :bigint not null 7 | # feature_id :bigint not null 8 | # created_at :datetime not null 9 | # updated_at :datetime not null 10 | # 11 | require "test_helper" 12 | 13 | class PropertyFeatureTest < ActiveSupport::TestCase 14 | # test "the truth" do 15 | # assert true 16 | # end 17 | end 18 | -------------------------------------------------------------------------------- /app/models/feature.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: features 4 | # 5 | # id :bigint not null, primary key 6 | # name :string 7 | # created_at :datetime not null 8 | # updated_at :datetime not null 9 | # 10 | class Feature < ApplicationRecord 11 | # Validaciones 12 | validates :name, presence: true, uniqueness: true 13 | 14 | # Relaciones 15 | has_many :property_features, dependent: :destroy 16 | has_many :properties, through: :property_features 17 | end 18 | -------------------------------------------------------------------------------- /app/views/devise/shared/_error_messages.html.erb: -------------------------------------------------------------------------------- 1 | <% if resource.errors.any? %> 2 |
3 |

4 | <%= I18n.t("errors.messages.not_saved", 5 | count: resource.errors.count, 6 | resource: resource.class.model_name.human.downcase) 7 | %> 8 |

9 | 14 |
15 | <% end %> 16 | -------------------------------------------------------------------------------- /app/models/property_feature.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: property_features 4 | # 5 | # id :bigint not null, primary key 6 | # property_id :bigint not null 7 | # feature_id :bigint not null 8 | # created_at :datetime not null 9 | # updated_at :datetime not null 10 | # 11 | class PropertyFeature < ApplicationRecord 12 | # Relaciones 13 | belongs_to :property 14 | belongs_to :feature 15 | 16 | # Validaciones 17 | validates :property, :feature, presence: true 18 | end 19 | -------------------------------------------------------------------------------- /config/initializers/permissions_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide HTTP permissions policy. For further 4 | # information see: https://developers.google.com/web/updates/2018/06/feature-policy 5 | 6 | # Rails.application.config.permissions_policy do |policy| 7 | # policy.camera :none 8 | # policy.gyroscope :none 9 | # policy.microphone :none 10 | # policy.usb :none 11 | # policy.fullscreen :self 12 | # policy.payment :self, "https://secure.example.com" 13 | # end 14 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = "1.0" 5 | 6 | # Add additional assets to the asset load path. 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | 9 | # Precompile additional assets. 10 | # application.js, application.css, and all non-JS/CSS in the app/assets 11 | # folder are already added. 12 | # Rails.application.config.assets.precompile += %w( admin.js admin.css ) 13 | -------------------------------------------------------------------------------- /app/models/contact.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: contacts 4 | # 5 | # id :bigint not null, primary key 6 | # name :string 7 | # email :string 8 | # message :text 9 | # created_at :datetime not null 10 | # updated_at :datetime not null 11 | # 12 | class Contact < ApplicationRecord 13 | # Validaciones 14 | validates :name, presence: true 15 | validates :email, presence: true, 16 | format: { with: URI::MailTo::EMAIL_REGEXP } 17 | validates :message, presence: true 18 | end 19 | -------------------------------------------------------------------------------- /app/views/devise/unlocks/new.html.erb: -------------------------------------------------------------------------------- 1 |

Resend unlock instructions

2 | 3 | <%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> 4 | <%= render "devise/shared/error_messages", resource: resource %> 5 | 6 |
7 | <%= f.label :email %>
8 | <%= f.email_field :email, autofocus: true, autocomplete: "email" %> 9 |
10 | 11 |
12 | <%= f.submit "Resend unlock instructions" %> 13 |
14 | <% end %> 15 | 16 | <%= render "devise/shared/links" %> 17 | -------------------------------------------------------------------------------- /app/views/devise/passwords/new.html.erb: -------------------------------------------------------------------------------- 1 |

Forgot your password?

2 | 3 | <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> 4 | <%= render "devise/shared/error_messages", resource: resource %> 5 | 6 |
7 | <%= f.label :email %>
8 | <%= f.email_field :email, autofocus: true, autocomplete: "email" %> 9 |
10 | 11 |
12 | <%= f.submit "Send me reset password instructions" %> 13 |
14 | <% end %> 15 | 16 | <%= render "devise/shared/links" %> 17 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | resources :properties 3 | # Devise 4 | devise_for :users, controllers: { registrations: 'registrations' }, 5 | path: '', 6 | path_names: { sign_in: 'login', 7 | sign_out: 'logout', 8 | sign_up: 'register' } 9 | 10 | # Contacts 11 | resources :contacts, only: %i[new create] 12 | 13 | # Paginas estaticas 14 | get '/home', to: 'pages#home' 15 | get '/terms', to: 'pages#terms' 16 | root "pages#home" 17 | end 18 | -------------------------------------------------------------------------------- /app/javascript/controllers/index.js: -------------------------------------------------------------------------------- 1 | // Import and register all your controllers from the importmap under controllers/* 2 | 3 | import { application } from "controllers/application" 4 | 5 | // Eager load all controllers defined in the import map under controllers/**/*_controller 6 | import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" 7 | eagerLoadControllersFrom("controllers", application) 8 | 9 | // Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!) 10 | // import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading" 11 | // lazyLoadControllersFrom("controllers", application) 12 | -------------------------------------------------------------------------------- /test/models/property_test.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: properties 4 | # 5 | # id :bigint not null, primary key 6 | # user_id :bigint not null 7 | # type_offer_id :bigint not null 8 | # type_property_id :bigint not null 9 | # description :text 10 | # area :integer 11 | # price :decimal(, ) 12 | # created_at :datetime not null 13 | # updated_at :datetime not null 14 | # 15 | require "test_helper" 16 | 17 | class PropertyTest < ActiveSupport::TestCase 18 | # test "the truth" do 19 | # assert true 20 | # end 21 | end 22 | -------------------------------------------------------------------------------- /app/views/devise/confirmations/new.html.erb: -------------------------------------------------------------------------------- 1 |

Resend confirmation instructions

2 | 3 | <%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> 4 | <%= render "devise/shared/error_messages", resource: resource %> 5 | 6 |
7 | <%= f.label :email %>
8 | <%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %> 9 |
10 | 11 |
12 | <%= f.submit "Resend confirmation instructions" %> 13 |
14 | <% end %> 15 | 16 | <%= render "devise/shared/links" %> 17 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, "\\1en" 8 | # inflect.singular /^(ox)en/i, "\\1" 9 | # inflect.irregular "person", "people" 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym "RESTful" 16 | # end 17 | -------------------------------------------------------------------------------- /app/controllers/registrations_controller.rb: -------------------------------------------------------------------------------- 1 | class RegistrationsController < Devise::RegistrationsController 2 | before_action :configure_permitted_parameters, if: :devise_controller? 3 | protect_from_forgery with: :exception 4 | 5 | protected 6 | 7 | def configure_permitted_parameters 8 | added_attrs = %i[ email password password_confirmation remember_me name phone role ] 9 | 10 | devise_parameter_sanitizer.permit :sign_up, keys: %i[email password password_confirmation name phone] 11 | devise_parameter_sanitizer.permit :sign_in, keys: %i[email password remember_me] 12 | devise_parameter_sanitizer.permit :account_update, keys: added_attrs 13 | end 14 | 15 | def update_resource(resource, params) 16 | resource.update_without_password(params) 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /app/views/devise/sessions/new.html.erb: -------------------------------------------------------------------------------- 1 |

Log in

2 | 3 | <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> 4 |
5 | <%= f.label :email %>
6 | <%= f.email_field :email, autofocus: true, autocomplete: "email" %> 7 |
8 | 9 |
10 | <%= f.label :password %>
11 | <%= f.password_field :password, autocomplete: "current-password" %> 12 |
13 | 14 | <% if devise_mapping.rememberable? %> 15 |
16 | <%= f.check_box :remember_me %> 17 | <%= f.label :remember_me %> 18 |
19 | <% end %> 20 | 21 |
22 | <%= f.submit "Log in" %> 23 |
24 | <% end %> 25 | 26 | <%= render "devise/shared/links" %> 27 | -------------------------------------------------------------------------------- /test/fixtures/properties.yml: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: properties 4 | # 5 | # id :bigint not null, primary key 6 | # user_id :bigint not null 7 | # type_offer_id :bigint not null 8 | # type_property_id :bigint not null 9 | # description :text 10 | # area :integer 11 | # price :decimal(, ) 12 | # created_at :datetime not null 13 | # updated_at :datetime not null 14 | # 15 | 16 | one: 17 | user: one 18 | type_offer: one 19 | type_property: one 20 | description: MyText 21 | area: 1 22 | price: 9.99 23 | 24 | two: 25 | user: two 26 | type_offer: two 27 | type_property: two 28 | description: MyText 29 | area: 1 30 | price: 9.99 31 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | require 'csv' 2 | 3 | # puts 'Importing typeProperties...' 4 | # CSV.foreach(Rails.root.join('db/seeds/csv/typeProperties.csv'), headers: true) do |row| 5 | # TypeProperty.create! do |type_property| 6 | # type_property.id = row[0] 7 | # type_property.name = row[1] 8 | # end 9 | # end 10 | 11 | # puts 'Importing typeOffers...' 12 | # CSV.foreach(Rails.root.join('db/seeds/csv/typeOffers.csv'), headers: true) do |row| 13 | # TypeOffer.create! do |type_offer| 14 | # type_offer.id = row[0] 15 | # type_offer.name = row[1] 16 | # end 17 | # end 18 | 19 | puts 'Importing features...' 20 | CSV.foreach(Rails.root.join('db/seeds/csv/features.csv'), headers: true) do |row| 21 | Feature.create! do |feature| 22 | feature.id = row[0] 23 | feature.name = row[1] 24 | end 25 | end -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's 6 | * vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /test/models/user_test.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: users 4 | # 5 | # id :bigint not null, primary key 6 | # email :string default(""), not null 7 | # encrypted_password :string default(""), not null 8 | # reset_password_token :string 9 | # reset_password_sent_at :datetime 10 | # remember_created_at :datetime 11 | # name :string 12 | # phone :bigint 13 | # role :integer default("regular") 14 | # created_at :datetime not null 15 | # updated_at :datetime not null 16 | # 17 | require "test_helper" 18 | 19 | class UserTest < ActiveSupport::TestCase 20 | # test "the truth" do 21 | # assert true 22 | # end 23 | end 24 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files. 2 | 3 | # Ignore git directory. 4 | /.git/ 5 | 6 | # Ignore bundler config. 7 | /.bundle 8 | 9 | # Ignore all environment files (except templates). 10 | /.env* 11 | !/.env*.erb 12 | 13 | # Ignore all default key files. 14 | /config/master.key 15 | /config/credentials/*.key 16 | 17 | # Ignore all logfiles and tempfiles. 18 | /log/* 19 | /tmp/* 20 | !/log/.keep 21 | !/tmp/.keep 22 | 23 | # Ignore pidfiles, but keep the directory. 24 | /tmp/pids/* 25 | !/tmp/pids/.keep 26 | 27 | # Ignore storage (uploaded files in development and any SQLite databases). 28 | /storage/* 29 | !/storage/.keep 30 | /tmp/storage/* 31 | !/tmp/storage/.keep 32 | 33 | # Ignore assets. 34 | /node_modules/ 35 | /app/assets/builds/* 36 | !/app/assets/builds/.keep 37 | /public/assets 38 | -------------------------------------------------------------------------------- /app/models/property.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: properties 4 | # 5 | # id :bigint not null, primary key 6 | # user_id :bigint not null 7 | # type_offer_id :bigint not null 8 | # type_property_id :bigint not null 9 | # description :text 10 | # area :integer 11 | # price :decimal(, ) 12 | # created_at :datetime not null 13 | # updated_at :datetime not null 14 | # 15 | class Property < ApplicationRecord 16 | # Relaciones 17 | belongs_to :user 18 | belongs_to :type_offer 19 | belongs_to :type_property 20 | # Relaciones 21 | has_many :property_features, dependent: :destroy 22 | has_many :features, through: :property_features 23 | 24 | # Validaciones 25 | validates :description, presence: true 26 | validates :area, presence: true 27 | validates :price, presence: true 28 | end 29 | -------------------------------------------------------------------------------- /app/views/contacts/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with(model: contact) do |form| %> 2 | <% if contact.errors.any? %> 3 |
4 |

<%= pluralize(contact.errors.count, "error") %> prohibited this contact from being saved:

5 | 6 | 11 |
12 | <% end %> 13 | 14 |
15 | <%= form.label :name, style: "display: block" %> 16 | <%= form.text_field :name, required: true %> 17 |
18 | 19 |
20 | <%= form.label :email, style: "display: block" %> 21 | <%= form.text_field :email, required: true %> 22 |
23 | 24 |
25 | <%= form.label :message, style: "display: block" %> 26 | <%= form.text_area :message, required: true %> 27 |
28 | 29 |
30 | <%= form.submit %> 31 |
32 | <% end %> 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore all environment files (except templates). 11 | /.env* 12 | !/.env*.erb 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/* 16 | /tmp/* 17 | !/log/.keep 18 | !/tmp/.keep 19 | 20 | # Ignore pidfiles, but keep the directory. 21 | /tmp/pids/* 22 | !/tmp/pids/ 23 | !/tmp/pids/.keep 24 | 25 | # Ignore storage (uploaded files in development and any SQLite databases). 26 | /storage/* 27 | !/storage/.keep 28 | /tmp/storage/* 29 | !/tmp/storage/ 30 | !/tmp/storage/.keep 31 | 32 | /public/assets 33 | 34 | # Ignore master key for decrypting credentials and more. 35 | /config/master.key 36 | -------------------------------------------------------------------------------- /test/fixtures/users.yml: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: users 4 | # 5 | # id :bigint not null, primary key 6 | # email :string default(""), not null 7 | # encrypted_password :string default(""), not null 8 | # reset_password_token :string 9 | # reset_password_sent_at :datetime 10 | # remember_created_at :datetime 11 | # name :string 12 | # phone :bigint 13 | # role :integer default("regular") 14 | # created_at :datetime not null 15 | # updated_at :datetime not null 16 | # 17 | 18 | # This model initially had no columns defined. If you add columns to the 19 | # model remove the "{}" from the fixture names and add the columns immediately 20 | # below each fixture, per the syntax in the comments below 21 | # 22 | one: {} 23 | # column: value 24 | # 25 | two: {} 26 | # column: value 27 | -------------------------------------------------------------------------------- /app/views/devise/passwords/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Change your password

2 | 3 | <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> 4 | <%= render "devise/shared/error_messages", resource: resource %> 5 | <%= f.hidden_field :reset_password_token %> 6 | 7 |
8 | <%= f.label :password, "New password" %>
9 | <% if @minimum_password_length %> 10 | (<%= @minimum_password_length %> characters minimum)
11 | <% end %> 12 | <%= f.password_field :password, autofocus: true, autocomplete: "new-password" %> 13 |
14 | 15 |
16 | <%= f.label :password_confirmation, "Confirm new password" %>
17 | <%= f.password_field :password_confirmation, autocomplete: "new-password" %> 18 |
19 | 20 |
21 | <%= f.submit "Change my password" %> 22 |
23 | <% end %> 24 | 25 | <%= render "devise/shared/links" %> 26 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization and 2 | # are automatically loaded by Rails. If you want to use locales other than 3 | # English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t "hello" 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t("hello") %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more about the API, please read the Rails Internationalization guide 20 | # at https://guides.rubyonrails.org/i18n.html. 21 | # 22 | # Be aware that YAML interprets the following case-insensitive strings as 23 | # booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings 24 | # must be quoted to be interpreted as strings. For example: 25 | # 26 | # en: 27 | # "yes": yup 28 | # enabled: "ON" 29 | 30 | en: 31 | hello: "Hello world" 32 | -------------------------------------------------------------------------------- /app/views/properties/_property.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 | <%# ... %> 4 |
5 |
6 | <%= property.type_property.name %> en <%= property.type_offer.name %> 7 |
8 |

<%= property.description %>

9 |

10 | Contacto: 11 | <%= property.user.name %>
12 | <%= property.user.email %>
13 | <%= property.user.phone %> 14 |

15 |

16 | Features: 17 | <% property.features.each do |item| %> 18 | <%= content_tag :span, item.name, class: "tag" %> 19 | <% end %> 20 |

21 | 22 |

23 | Area: 24 | <%= property.area %> 25 |

26 | 27 |

28 | Price: 29 | <%= property.price %> 30 |

31 |
32 |
33 | 34 | 35 | 36 |
37 | -------------------------------------------------------------------------------- /app/controllers/contacts_controller.rb: -------------------------------------------------------------------------------- 1 | class ContactsController < ApplicationController 2 | 3 | # GET /contacts/new 4 | def new 5 | @contact = Contact.new 6 | end 7 | 8 | # POST /contacts or /contacts.json 9 | def create 10 | @contact = Contact.new(contact_params) 11 | 12 | respond_to do |format| 13 | if @contact.save 14 | format.html { redirect_to root_path, notice: "Contact was successfully created." } 15 | format.json { render :show, status: :created, location: @contact } 16 | else 17 | format.html { render :new, status: :unprocessable_entity } 18 | format.json { render json: @contact.errors, status: :unprocessable_entity } 19 | end 20 | end 21 | end 22 | 23 | private 24 | # Use callbacks to share common setup or constraints between actions. 25 | def set_contact 26 | @contact = Contact.find(params[:id]) 27 | end 28 | 29 | # Only allow a list of trusted parameters through. 30 | def contact_params 31 | params.require(:contact).permit(:name, :email, :message) 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative "boot" 2 | 3 | require "rails/all" 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module InforcapHouse 10 | class Application < Rails::Application 11 | # Initialize configuration defaults for originally generated Rails version. 12 | config.load_defaults 7.1 13 | 14 | # Please, add to the `ignore` list any other `lib` subdirectories that do 15 | # not contain `.rb` files, or that should not be reloaded or eager loaded. 16 | # Common ones are `templates`, `generators`, or `middleware`, for example. 17 | config.autoload_lib(ignore: %w(assets tasks)) 18 | 19 | # Configuration for the application, engines, and railties goes here. 20 | # 21 | # These settings can be overridden in specific environments using the files 22 | # in config/environments, which are processed later. 23 | # 24 | # config.time_zone = "Central Time (US & Canada)" 25 | # config.eager_load_paths << Rails.root.join("extras") 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "fileutils" 3 | 4 | # path to your application root. 5 | APP_ROOT = File.expand_path("..", __dir__) 6 | 7 | def system!(*args) 8 | system(*args, exception: true) 9 | end 10 | 11 | FileUtils.chdir APP_ROOT do 12 | # This script is a way to set up or update your development environment automatically. 13 | # This script is idempotent, so that you can run it at any time and get an expectable outcome. 14 | # Add necessary setup steps to this file. 15 | 16 | puts "== Installing dependencies ==" 17 | system! "gem install bundler --conservative" 18 | system("bundle check") || system!("bundle install") 19 | 20 | # puts "\n== Copying sample files ==" 21 | # unless File.exist?("config/database.yml") 22 | # FileUtils.cp "config/database.yml.sample", "config/database.yml" 23 | # end 24 | 25 | puts "\n== Preparing database ==" 26 | system! "bin/rails db:prepare" 27 | 28 | puts "\n== Removing old logs and tempfiles ==" 29 | system! "bin/rails log:clear tmp:clear" 30 | 31 | puts "\n== Restarting application server ==" 32 | system! "bin/rails restart" 33 | end 34 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | InforcapHouse 5 | 6 | <%= csrf_meta_tags %> 7 | <%= csp_meta_tag %> 8 | 9 | <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> 10 | <%= javascript_importmap_tags %> 11 | 12 | 13 | 14 | 15 | 16 | <%= render "shared/navbar" %> 17 |

<%= notice %>

18 |

<%= alert %>

19 |
20 |
21 |
22 | <%= yield %> 23 |
24 |
25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: users 4 | # 5 | # id :bigint not null, primary key 6 | # email :string default(""), not null 7 | # encrypted_password :string default(""), not null 8 | # reset_password_token :string 9 | # reset_password_sent_at :datetime 10 | # remember_created_at :datetime 11 | # name :string 12 | # phone :bigint 13 | # role :integer default("regular") 14 | # created_at :datetime not null 15 | # updated_at :datetime not null 16 | # 17 | class User < ApplicationRecord 18 | # Include default devise modules. Others available are: 19 | # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable 20 | devise :database_authenticatable, :registerable, 21 | :recoverable, :rememberable, :validatable 22 | 23 | # Validaciones 24 | validates :name, presence: true 25 | validates :phone, presence: true 26 | enum role: [:regular, :admin] 27 | 28 | # Relaciones 29 | has_many :properties, dependent: :destroy 30 | end 31 | -------------------------------------------------------------------------------- /config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide content security policy. 4 | # See the Securing Rails Applications Guide for more information: 5 | # https://guides.rubyonrails.org/security.html#content-security-policy-header 6 | 7 | # Rails.application.configure do 8 | # config.content_security_policy do |policy| 9 | # policy.default_src :self, :https 10 | # policy.font_src :self, :https, :data 11 | # policy.img_src :self, :https, :data 12 | # policy.object_src :none 13 | # policy.script_src :self, :https 14 | # policy.style_src :self, :https 15 | # # Specify URI for violation reports 16 | # # policy.report_uri "/csp-violation-report-endpoint" 17 | # end 18 | # 19 | # # Generate session nonces for permitted importmap, inline scripts, and inline styles. 20 | # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } 21 | # config.content_security_policy_nonce_directives = %w(script-src style-src) 22 | # 23 | # # Report violations without enforcing the policy. 24 | # # config.content_security_policy_report_only = true 25 | # end 26 | -------------------------------------------------------------------------------- /app/views/devise/registrations/new.html.erb: -------------------------------------------------------------------------------- 1 |

Sign up

2 | 3 | <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> 4 | <%= render "devise/shared/error_messages", resource: resource %> 5 | 6 |
7 | <%= f.label :name %>
8 | <%= f.text_field :name, autofocus: true, autocomplete: "name" %> 9 |
10 | 11 |
12 | <%= f.label :phone %>
13 | <%= f.number_field :phone, autocomplete: "phone" %> 14 |
15 | 16 |
17 | <%= f.label :email %>
18 | <%= f.email_field :email, autocomplete: "email" %> 19 |
20 | 21 |
22 | <%= f.label :password %> 23 | <% if @minimum_password_length %> 24 | (<%= @minimum_password_length %> characters minimum) 25 | <% end %>
26 | <%= f.password_field :password, autocomplete: "new-password" %> 27 |
28 | 29 |
30 | <%= f.label :password_confirmation %>
31 | <%= f.password_field :password_confirmation, autocomplete: "new-password" %> 32 |
33 | 34 |
35 | <%= f.submit "Sign up" %> 36 |
37 | <% end %> 38 | 39 | <%= render "devise/shared/links" %> 40 | -------------------------------------------------------------------------------- /app/views/devise/shared/_links.html.erb: -------------------------------------------------------------------------------- 1 | <%- if controller_name != 'sessions' %> 2 | <%= link_to "Log in", new_session_path(resource_name) %>
3 | <% end %> 4 | 5 | <%- if devise_mapping.registerable? && controller_name != 'registrations' %> 6 | <%= link_to "Sign up", new_registration_path(resource_name) %>
7 | <% end %> 8 | 9 | <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> 10 | <%= link_to "Forgot your password?", new_password_path(resource_name) %>
11 | <% end %> 12 | 13 | <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> 14 | <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
15 | <% end %> 16 | 17 | <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> 18 | <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
19 | <% end %> 20 | 21 | <%- if devise_mapping.omniauthable? %> 22 | <%- resource_class.omniauth_providers.each do |provider| %> 23 | <%= button_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), data: { turbo: false } %>
24 | <% end %> 25 | <% end %> 26 | -------------------------------------------------------------------------------- /config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket-<%= Rails.env %> 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket-<%= Rails.env %> 23 | 24 | # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name-<%= Rails.env %> 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /test/system/contacts_test.rb: -------------------------------------------------------------------------------- 1 | require "application_system_test_case" 2 | 3 | class ContactsTest < ApplicationSystemTestCase 4 | setup do 5 | @contact = contacts(:one) 6 | end 7 | 8 | test "visiting the index" do 9 | visit contacts_url 10 | assert_selector "h1", text: "Contacts" 11 | end 12 | 13 | test "should create contact" do 14 | visit contacts_url 15 | click_on "New contact" 16 | 17 | fill_in "Email", with: @contact.email 18 | fill_in "Message", with: @contact.message 19 | fill_in "Name", with: @contact.name 20 | click_on "Create Contact" 21 | 22 | assert_text "Contact was successfully created" 23 | click_on "Back" 24 | end 25 | 26 | test "should update Contact" do 27 | visit contact_url(@contact) 28 | click_on "Edit this contact", match: :first 29 | 30 | fill_in "Email", with: @contact.email 31 | fill_in "Message", with: @contact.message 32 | fill_in "Name", with: @contact.name 33 | click_on "Update Contact" 34 | 35 | assert_text "Contact was successfully updated" 36 | click_on "Back" 37 | end 38 | 39 | test "should destroy Contact" do 40 | visit contact_url(@contact) 41 | click_on "Destroy this contact", match: :first 42 | 43 | assert_text "Contact was successfully destroyed" 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /test/controllers/contacts_controller_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class ContactsControllerTest < ActionDispatch::IntegrationTest 4 | setup do 5 | @contact = contacts(:one) 6 | end 7 | 8 | test "should get index" do 9 | get contacts_url 10 | assert_response :success 11 | end 12 | 13 | test "should get new" do 14 | get new_contact_url 15 | assert_response :success 16 | end 17 | 18 | test "should create contact" do 19 | assert_difference("Contact.count") do 20 | post contacts_url, params: { contact: { email: @contact.email, message: @contact.message, name: @contact.name } } 21 | end 22 | 23 | assert_redirected_to contact_url(Contact.last) 24 | end 25 | 26 | test "should show contact" do 27 | get contact_url(@contact) 28 | assert_response :success 29 | end 30 | 31 | test "should get edit" do 32 | get edit_contact_url(@contact) 33 | assert_response :success 34 | end 35 | 36 | test "should update contact" do 37 | patch contact_url(@contact), params: { contact: { email: @contact.email, message: @contact.message, name: @contact.name } } 38 | assert_redirected_to contact_url(@contact) 39 | end 40 | 41 | test "should destroy contact" do 42 | assert_difference("Contact.count", -1) do 43 | delete contact_url(@contact) 44 | end 45 | 46 | assert_redirected_to contacts_url 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /app/views/properties/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with(model: property) do |form| %> 2 | <% if property.errors.any? %> 3 |
4 |

<%= pluralize(property.errors.count, "error") %> prohibited this property from being saved:

5 | 6 | 11 |
12 | <% end %> 13 | 14 |
15 | <%= form.label :user_id, style: "display: block" %> 16 | <%= form.collection_select :user_id, User.all, :id, :name %> 17 |
18 | 19 |
20 | <%= form.label :type_offer_id, style: "display: block" %> 21 | <%= form.collection_select :type_offer_id, TypeOffer.all, :id, :name %> 22 |
23 | 24 |
25 | <%= form.label :type_property_id, style: "display: block" %> 26 | <%= form.collection_select :type_property_id, TypeProperty.all, :id, :name %> 27 |
28 | 29 |
30 | <%= form.label :features, style: "display: block" %> 31 | <%= form.collection_check_boxes :feature_ids, Feature.all, :id, :name %> 32 |
33 | 34 |
35 | <%= form.label :description, style: "display: block" %> 36 | <%= form.text_area :description, required: true %> 37 |
38 | 39 |
40 | <%= form.label :area, style: "display: block" %> 41 | <%= form.number_field :area, required: true %> 42 |
43 | 44 |
45 | <%= form.label :price, style: "display: block" %> 46 | <%= form.text_field :price, required: true %> 47 |
48 | 49 |
50 | <%= form.submit %> 51 |
52 | <% end %> 53 | -------------------------------------------------------------------------------- /test/controllers/properties_controller_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class PropertiesControllerTest < ActionDispatch::IntegrationTest 4 | setup do 5 | @property = properties(:one) 6 | end 7 | 8 | test "should get index" do 9 | get properties_url 10 | assert_response :success 11 | end 12 | 13 | test "should get new" do 14 | get new_property_url 15 | assert_response :success 16 | end 17 | 18 | test "should create property" do 19 | assert_difference("Property.count") do 20 | post properties_url, params: { property: { area: @property.area, description: @property.description, price: @property.price, type_offer_id: @property.type_offer_id, type_property_id: @property.type_property_id, user_id: @property.user_id } } 21 | end 22 | 23 | assert_redirected_to property_url(Property.last) 24 | end 25 | 26 | test "should show property" do 27 | get property_url(@property) 28 | assert_response :success 29 | end 30 | 31 | test "should get edit" do 32 | get edit_property_url(@property) 33 | assert_response :success 34 | end 35 | 36 | test "should update property" do 37 | patch property_url(@property), params: { property: { area: @property.area, description: @property.description, price: @property.price, type_offer_id: @property.type_offer_id, type_property_id: @property.type_property_id, user_id: @property.user_id } } 38 | assert_redirected_to property_url(@property) 39 | end 40 | 41 | test "should destroy property" do 42 | assert_difference("Property.count", -1) do 43 | delete property_url(@property) 44 | end 45 | 46 | assert_redirected_to properties_url 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /test/system/properties_test.rb: -------------------------------------------------------------------------------- 1 | require "application_system_test_case" 2 | 3 | class PropertiesTest < ApplicationSystemTestCase 4 | setup do 5 | @property = properties(:one) 6 | end 7 | 8 | test "visiting the index" do 9 | visit properties_url 10 | assert_selector "h1", text: "Properties" 11 | end 12 | 13 | test "should create property" do 14 | visit properties_url 15 | click_on "New property" 16 | 17 | fill_in "Area", with: @property.area 18 | fill_in "Description", with: @property.description 19 | fill_in "Price", with: @property.price 20 | fill_in "Type offer", with: @property.type_offer_id 21 | fill_in "Type property", with: @property.type_property_id 22 | fill_in "User", with: @property.user_id 23 | click_on "Create Property" 24 | 25 | assert_text "Property was successfully created" 26 | click_on "Back" 27 | end 28 | 29 | test "should update Property" do 30 | visit property_url(@property) 31 | click_on "Edit this property", match: :first 32 | 33 | fill_in "Area", with: @property.area 34 | fill_in "Description", with: @property.description 35 | fill_in "Price", with: @property.price 36 | fill_in "Type offer", with: @property.type_offer_id 37 | fill_in "Type property", with: @property.type_property_id 38 | fill_in "User", with: @property.user_id 39 | click_on "Update Property" 40 | 41 | assert_text "Property was successfully updated" 42 | click_on "Back" 43 | end 44 | 45 | test "should destroy Property" do 46 | visit property_url(@property) 47 | click_on "Destroy this property", match: :first 48 | 49 | assert_text "Property was successfully destroyed" 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /db/migrate/20231007133131_devise_create_users.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class DeviseCreateUsers < ActiveRecord::Migration[7.1] 4 | def change 5 | create_table :users do |t| 6 | ## Database authenticatable 7 | t.string :email, null: false, default: "" 8 | t.string :encrypted_password, null: false, default: "" 9 | 10 | ## Recoverable 11 | t.string :reset_password_token 12 | t.datetime :reset_password_sent_at 13 | 14 | ## Rememberable 15 | t.datetime :remember_created_at 16 | 17 | ## Trackable 18 | # t.integer :sign_in_count, default: 0, null: false 19 | # t.datetime :current_sign_in_at 20 | # t.datetime :last_sign_in_at 21 | # t.string :current_sign_in_ip 22 | # t.string :last_sign_in_ip 23 | 24 | ## Confirmable 25 | # t.string :confirmation_token 26 | # t.datetime :confirmed_at 27 | # t.datetime :confirmation_sent_at 28 | # t.string :unconfirmed_email # Only if using reconfirmable 29 | 30 | ## Lockable 31 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts 32 | # t.string :unlock_token # Only if unlock strategy is :email or :both 33 | # t.datetime :locked_at 34 | 35 | t.string :name 36 | t.bigint :phone 37 | t.integer :role, default: 0 38 | 39 | t.timestamps null: false 40 | end 41 | 42 | add_index :users, :email, unique: true 43 | add_index :users, :reset_password_token, unique: true 44 | # add_index :users, :confirmation_token, unique: true 45 | # add_index :users, :unlock_token, unique: true 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /app/views/devise/registrations/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Edit <%= resource_name.to_s.humanize %>

2 | 3 | <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> 4 | <%= render "devise/shared/error_messages", resource: resource %> 5 | 6 |
7 | <%= f.label :email %>
8 | <%= f.email_field :email, autofocus: true, autocomplete: "email" %> 9 |
10 | 11 | <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> 12 |
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
13 | <% end %> 14 | 15 |
16 | <%= f.label :password %> (leave blank if you don't want to change it)
17 | <%= f.password_field :password, autocomplete: "new-password" %> 18 | <% if @minimum_password_length %> 19 |
20 | <%= @minimum_password_length %> characters minimum 21 | <% end %> 22 |
23 | 24 |
25 | <%= f.label :password_confirmation %>
26 | <%= f.password_field :password_confirmation, autocomplete: "new-password" %> 27 |
28 | 29 |
30 | <%= f.label :current_password %> (we need your current password to confirm your changes)
31 | <%= f.password_field :current_password, autocomplete: "current-password" %> 32 |
33 | 34 |
35 | <%= f.submit "Update" %> 36 |
37 | <% end %> 38 | 39 |

Cancel my account

40 | 41 |
Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?" }, method: :delete %>
42 | 43 | <%= link_to "Back", :back %> 44 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # This configuration file will be evaluated by Puma. The top-level methods that 2 | # are invoked here are part of Puma's configuration DSL. For more information 3 | # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. 4 | 5 | # Puma can serve each request in a thread from an internal thread pool. 6 | # The `threads` method setting takes two numbers: a minimum and maximum. 7 | # Any libraries that use thread pools should be configured to match 8 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 9 | # and maximum; this matches the default thread size of Active Record. 10 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 11 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } 12 | threads min_threads_count, max_threads_count 13 | 14 | # Specifies that the worker count should equal the number of processors in production. 15 | if ENV["RAILS_ENV"] == "production" 16 | require "concurrent-ruby" 17 | worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count }) 18 | workers worker_count if worker_count > 1 19 | end 20 | 21 | # Specifies the `worker_timeout` threshold that Puma will use to wait before 22 | # terminating a worker in development environments. 23 | worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" 24 | 25 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 26 | port ENV.fetch("PORT") { 3000 } 27 | 28 | # Specifies the `environment` that Puma will run in. 29 | environment ENV.fetch("RAILS_ENV") { "development" } 30 | 31 | # Specifies the `pidfile` that Puma will use. 32 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } 33 | 34 | # Allow puma to be restarted by `bin/rails restart` command. 35 | plugin :tmp_restart 36 | -------------------------------------------------------------------------------- /app/views/shared/_navbar.html.erb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = docker/dockerfile:1 2 | 3 | # Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile 4 | ARG RUBY_VERSION=3.2.2 5 | FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base 6 | 7 | # Rails app lives here 8 | WORKDIR /rails 9 | 10 | # Set production environment 11 | ENV RAILS_ENV="production" \ 12 | BUNDLE_DEPLOYMENT="1" \ 13 | BUNDLE_PATH="/usr/local/bundle" \ 14 | BUNDLE_WITHOUT="development" 15 | 16 | 17 | # Throw-away build stage to reduce size of final image 18 | FROM base as build 19 | 20 | # Install packages needed to build gems 21 | RUN apt-get update -qq && \ 22 | apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config 23 | 24 | # Install application gems 25 | COPY Gemfile Gemfile.lock ./ 26 | RUN bundle install && \ 27 | rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ 28 | bundle exec bootsnap precompile --gemfile 29 | 30 | # Copy application code 31 | COPY . . 32 | 33 | # Precompile bootsnap code for faster boot times 34 | RUN bundle exec bootsnap precompile app/ lib/ 35 | 36 | # Precompiling assets for production without requiring secret RAILS_MASTER_KEY 37 | RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile 38 | 39 | 40 | # Final stage for app image 41 | FROM base 42 | 43 | # Install packages needed for deployment 44 | RUN apt-get update -qq && \ 45 | apt-get install --no-install-recommends -y curl libvips postgresql-client && \ 46 | rm -rf /var/lib/apt/lists /var/cache/apt/archives 47 | 48 | # Copy built artifacts: gems, application 49 | COPY --from=build /usr/local/bundle /usr/local/bundle 50 | COPY --from=build /rails /rails 51 | 52 | # Run and own only the runtime files as a non-root user for security 53 | RUN useradd rails --create-home --shell /bin/bash && \ 54 | chown -R rails:rails db log storage tmp 55 | USER rails:rails 56 | 57 | # Entrypoint prepares the database. 58 | ENTRYPOINT ["/rails/bin/docker-entrypoint"] 59 | 60 | # Start the server by default, this can be overwritten at runtime 61 | EXPOSE 3000 62 | CMD ["./bin/rails", "server"] 63 | -------------------------------------------------------------------------------- /app/controllers/properties_controller.rb: -------------------------------------------------------------------------------- 1 | class PropertiesController < ApplicationController 2 | before_action :set_property, only: %i[ show edit update destroy ] 3 | before_action :authenticate_user!, except: %i[ index show ] 4 | 5 | # GET /properties or /properties.json 6 | def index 7 | # @properties = Property.all 8 | @pagy, @properties = pagy(Property.all) 9 | end 10 | 11 | # GET /properties/1 or /properties/1.json 12 | def show 13 | end 14 | 15 | # GET /properties/new 16 | def new 17 | @property = current_user.properties.build 18 | end 19 | 20 | # GET /properties/1/edit 21 | def edit 22 | end 23 | 24 | # POST /properties or /properties.json 25 | def create 26 | @property = current_user.properties.build(property_params) 27 | 28 | respond_to do |format| 29 | if @property.save 30 | format.html { redirect_to property_url(@property), notice: "Property was successfully created." } 31 | format.json { render :show, status: :created, location: @property } 32 | else 33 | format.html { render :new, status: :unprocessable_entity } 34 | format.json { render json: @property.errors, status: :unprocessable_entity } 35 | end 36 | end 37 | end 38 | 39 | # PATCH/PUT /properties/1 or /properties/1.json 40 | def update 41 | respond_to do |format| 42 | if @property.update(property_params) 43 | format.html { redirect_to property_url(@property), notice: "Property was successfully updated." } 44 | format.json { render :show, status: :ok, location: @property } 45 | else 46 | format.html { render :edit, status: :unprocessable_entity } 47 | format.json { render json: @property.errors, status: :unprocessable_entity } 48 | end 49 | end 50 | end 51 | 52 | # DELETE /properties/1 or /properties/1.json 53 | def destroy 54 | @property.destroy! 55 | 56 | respond_to do |format| 57 | format.html { redirect_to properties_url, notice: "Property was successfully destroyed." } 58 | format.json { head :no_content } 59 | end 60 | end 61 | 62 | private 63 | # Use callbacks to share common setup or constraints between actions. 64 | def set_property 65 | @property = Property.find(params[:id]) 66 | end 67 | 68 | # Only allow a list of trusted parameters through. 69 | def property_params 70 | params.require(:property).permit(:user_id, :type_offer_id, :type_property_id, :description, :area, :price, feature_ids: []) 71 | end 72 | end 73 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | ruby "3.2.2" 4 | 5 | # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" 6 | gem "rails", "~> 7.1.0" 7 | 8 | # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] 9 | gem "sprockets-rails" 10 | 11 | # Use postgresql as the database for Active Record 12 | gem "pg", "~> 1.1" 13 | 14 | # Use the Puma web server [https://github.com/puma/puma] 15 | gem "puma", ">= 5.0" 16 | 17 | # Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] 18 | gem "importmap-rails" 19 | 20 | # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] 21 | gem "turbo-rails" 22 | 23 | # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] 24 | gem "stimulus-rails" 25 | 26 | # Build JSON APIs with ease [https://github.com/rails/jbuilder] 27 | gem "jbuilder" 28 | 29 | # Use Redis adapter to run Action Cable in production 30 | # gem "redis", ">= 4.0.1" 31 | 32 | # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] 33 | # gem "kredis" 34 | 35 | # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] 36 | # gem "bcrypt", "~> 3.1.7" 37 | 38 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 39 | gem "tzinfo-data", platforms: %i[ windows jruby ] 40 | 41 | # Reduces boot times through caching; required in config/boot.rb 42 | gem "bootsnap", require: false 43 | 44 | # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] 45 | # gem "image_processing", "~> 1.2" 46 | 47 | group :development, :test do 48 | # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem 49 | gem "debug", platforms: %i[ mri windows ] 50 | end 51 | 52 | group :development do 53 | # Use console on exceptions pages [https://github.com/rails/web-console] 54 | gem "web-console" 55 | 56 | # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] 57 | # gem "rack-mini-profiler" 58 | 59 | # Speed up commands on slow machines / big apps [https://github.com/rails/spring] 60 | # gem "spring" 61 | 62 | end 63 | 64 | group :test do 65 | # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] 66 | gem "capybara" 67 | gem "selenium-webdriver" 68 | end 69 | 70 | gem "annotate", "~> 3.2" 71 | 72 | gem "faker", "~> 3.2" 73 | 74 | gem "devise", "~> 4.9" 75 | 76 | gem "pagy", "~> 6.1" 77 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | # The test environment is used exclusively to run your application's 4 | # test suite. You never need to work with it otherwise. Remember that 5 | # your test database is "scratch space" for the test suite and is wiped 6 | # and recreated between test runs. Don't rely on the data there! 7 | 8 | Rails.application.configure do 9 | # Settings specified here will take precedence over those in config/application.rb. 10 | 11 | # While tests run files are not watched, reloading is not necessary. 12 | config.enable_reloading = false 13 | 14 | # Eager loading loads your entire application. When running a single test locally, 15 | # this is usually not necessary, and can slow down your test suite. However, it's 16 | # recommended that you enable it in continuous integration systems to ensure eager 17 | # loading is working properly before deploying your code. 18 | config.eager_load = ENV["CI"].present? 19 | 20 | # Configure public file server for tests with Cache-Control for performance. 21 | config.public_file_server.enabled = true 22 | config.public_file_server.headers = { 23 | "Cache-Control" => "public, max-age=#{1.hour.to_i}" 24 | } 25 | 26 | # Show full error reports and disable caching. 27 | config.consider_all_requests_local = true 28 | config.action_controller.perform_caching = false 29 | config.cache_store = :null_store 30 | 31 | # Raise exceptions instead of rendering exception templates. 32 | config.action_dispatch.show_exceptions = :rescuable 33 | 34 | # Disable request forgery protection in test environment. 35 | config.action_controller.allow_forgery_protection = false 36 | 37 | # Store uploaded files on the local file system in a temporary directory. 38 | config.active_storage.service = :test 39 | 40 | config.action_mailer.perform_caching = false 41 | 42 | # Tell Action Mailer not to deliver emails to the real world. 43 | # The :test delivery method accumulates sent emails in the 44 | # ActionMailer::Base.deliveries array. 45 | config.action_mailer.delivery_method = :test 46 | 47 | # Print deprecation notices to the stderr. 48 | config.active_support.deprecation = :stderr 49 | 50 | # Raise exceptions for disallowed deprecations. 51 | config.active_support.disallowed_deprecation = :raise 52 | 53 | # Tell Active Support which deprecation messages to disallow. 54 | config.active_support.disallowed_deprecation_warnings = [] 55 | 56 | # Raises error for missing translations. 57 | # config.i18n.raise_on_missing_translations = true 58 | 59 | # Annotate rendered view with file names. 60 | # config.action_view.annotate_rendered_view_with_filenames = true 61 | 62 | # Raise error when a before_action's only/except options reference missing actions 63 | config.action_controller.raise_on_missing_callback_actions = true 64 | end 65 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | Rails.application.configure do 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # In the development environment your application's code is reloaded any time 7 | # it changes. This slows down response time but is perfect for development 8 | # since you don't have to restart the web server when you make code changes. 9 | config.enable_reloading = true 10 | 11 | # Do not eager load code on boot. 12 | config.eager_load = false 13 | 14 | # Show full error reports. 15 | config.consider_all_requests_local = true 16 | 17 | # Enable server timing 18 | config.server_timing = true 19 | 20 | # Enable/disable caching. By default caching is disabled. 21 | # Run rails dev:cache to toggle caching. 22 | if Rails.root.join("tmp/caching-dev.txt").exist? 23 | config.action_controller.perform_caching = true 24 | config.action_controller.enable_fragment_cache_logging = true 25 | 26 | config.cache_store = :memory_store 27 | config.public_file_server.headers = { 28 | "Cache-Control" => "public, max-age=#{2.days.to_i}" 29 | } 30 | else 31 | config.action_controller.perform_caching = false 32 | 33 | config.cache_store = :null_store 34 | end 35 | 36 | # Store uploaded files on the local file system (see config/storage.yml for options). 37 | config.active_storage.service = :local 38 | 39 | # Don't care if the mailer can't send. 40 | config.action_mailer.raise_delivery_errors = false 41 | 42 | config.action_mailer.perform_caching = false 43 | 44 | # Print deprecation notices to the Rails logger. 45 | config.active_support.deprecation = :log 46 | 47 | # Raise exceptions for disallowed deprecations. 48 | config.active_support.disallowed_deprecation = :raise 49 | 50 | # Tell Active Support which deprecation messages to disallow. 51 | config.active_support.disallowed_deprecation_warnings = [] 52 | 53 | # Raise an error on page load if there are pending migrations. 54 | config.active_record.migration_error = :page_load 55 | 56 | # Highlight code that triggered database queries in logs. 57 | config.active_record.verbose_query_logs = true 58 | 59 | # Highlight code that enqueued background job in logs. 60 | config.active_job.verbose_enqueue_logs = true 61 | 62 | # Suppress logger output for asset requests. 63 | config.assets.quiet = true 64 | 65 | # Raises error for missing translations. 66 | # config.i18n.raise_on_missing_translations = true 67 | 68 | # Annotate rendered view with file names. 69 | # config.action_view.annotate_rendered_view_with_filenames = true 70 | 71 | # Uncomment if you wish to allow Action Cable access from any origin. 72 | # config.action_cable.disable_request_forgery_protection = true 73 | 74 | # Raise error when a before_action's only/except options reference missing actions 75 | config.action_controller.raise_on_missing_callback_actions = true 76 | end 77 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # PostgreSQL. Versions 9.3 and up are supported. 2 | # 3 | # Install the pg driver: 4 | # gem install pg 5 | # On macOS with Homebrew: 6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config 7 | # On Windows: 8 | # gem install pg 9 | # Choose the win32 build. 10 | # Install PostgreSQL and put its /bin directory on your path. 11 | # 12 | # Configure Using Gemfile 13 | # gem "pg" 14 | # 15 | default: &default 16 | adapter: postgresql 17 | encoding: unicode 18 | # For details on connection pooling, see Rails configuration guide 19 | # https://guides.rubyonrails.org/configuring.html#database-pooling 20 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 21 | 22 | development: 23 | <<: *default 24 | database: inforcap_house_development 25 | 26 | # The specified database role being used to connect to postgres. 27 | # To create additional roles in postgres see `$ createuser --help`. 28 | # When left blank, postgres will use the default role. This is 29 | # the same name as the operating system user running Rails. 30 | #username: inforcap_house 31 | 32 | # The password associated with the postgres role (username). 33 | #password: 34 | 35 | # Connect on a TCP socket. Omitted by default since the client uses a 36 | # domain socket that doesn't need configuration. Windows does not have 37 | # domain sockets, so uncomment these lines. 38 | #host: localhost 39 | 40 | # The TCP port the server listens on. Defaults to 5432. 41 | # If your server runs on a different port number, change accordingly. 42 | #port: 5432 43 | 44 | # Schema search path. The server defaults to $user,public 45 | #schema_search_path: myapp,sharedapp,public 46 | 47 | # Minimum log levels, in increasing order: 48 | # debug5, debug4, debug3, debug2, debug1, 49 | # log, notice, warning, error, fatal, and panic 50 | # Defaults to warning. 51 | #min_messages: notice 52 | 53 | # Warning: The database defined as "test" will be erased and 54 | # re-generated from your development database when you run "rake". 55 | # Do not set this db to the same as development or production. 56 | test: 57 | <<: *default 58 | database: inforcap_house_test 59 | 60 | # As with config/credentials.yml, you never want to store sensitive information, 61 | # like your database password, in your source code. If your source code is 62 | # ever seen by anyone, they now have access to your database. 63 | # 64 | # Instead, provide the password or a full connection URL as an environment 65 | # variable when you boot the app. For example: 66 | # 67 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" 68 | # 69 | # If the connection URL is provided in the special DATABASE_URL environment 70 | # variable, Rails will automatically merge its configuration values on top of 71 | # the values provided in this file. Alternatively, you can specify a connection 72 | # URL environment variable explicitly: 73 | # 74 | # production: 75 | # url: <%= ENV["MY_APP_DATABASE_URL"] %> 76 | # 77 | # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database 78 | # for a full overview on how database connection configuration can be specified. 79 | # 80 | production: 81 | <<: *default 82 | database: inforcap_house_production 83 | username: inforcap_house 84 | password: <%= ENV["INFORCAP_HOUSE_DATABASE_PASSWORD"] %> 85 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'bundle' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require "rubygems" 12 | 13 | m = Module.new do 14 | module_function 15 | 16 | def invoked_as_script? 17 | File.expand_path($0) == File.expand_path(__FILE__) 18 | end 19 | 20 | def env_var_version 21 | ENV["BUNDLER_VERSION"] 22 | end 23 | 24 | def cli_arg_version 25 | return unless invoked_as_script? # don't want to hijack other binstubs 26 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` 27 | bundler_version = nil 28 | update_index = nil 29 | ARGV.each_with_index do |a, i| 30 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN 31 | bundler_version = a 32 | end 33 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ 34 | bundler_version = $1 35 | update_index = i 36 | end 37 | bundler_version 38 | end 39 | 40 | def gemfile 41 | gemfile = ENV["BUNDLE_GEMFILE"] 42 | return gemfile if gemfile && !gemfile.empty? 43 | 44 | File.expand_path("../Gemfile", __dir__) 45 | end 46 | 47 | def lockfile 48 | lockfile = 49 | case File.basename(gemfile) 50 | when "gems.rb" then gemfile.sub(/\.rb$/, ".locked") 51 | else "#{gemfile}.lock" 52 | end 53 | File.expand_path(lockfile) 54 | end 55 | 56 | def lockfile_version 57 | return unless File.file?(lockfile) 58 | lockfile_contents = File.read(lockfile) 59 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ 60 | Regexp.last_match(1) 61 | end 62 | 63 | def bundler_requirement 64 | @bundler_requirement ||= 65 | env_var_version || 66 | cli_arg_version || 67 | bundler_requirement_for(lockfile_version) 68 | end 69 | 70 | def bundler_requirement_for(version) 71 | return "#{Gem::Requirement.default}.a" unless version 72 | 73 | bundler_gem_version = Gem::Version.new(version) 74 | 75 | bundler_gem_version.approximate_recommendation 76 | end 77 | 78 | def load_bundler! 79 | ENV["BUNDLE_GEMFILE"] ||= gemfile 80 | 81 | activate_bundler 82 | end 83 | 84 | def activate_bundler 85 | gem_error = activation_error_handling do 86 | gem "bundler", bundler_requirement 87 | end 88 | return if gem_error.nil? 89 | require_error = activation_error_handling do 90 | require "bundler/version" 91 | end 92 | return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) 93 | warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" 94 | exit 42 95 | end 96 | 97 | def activation_error_handling 98 | yield 99 | nil 100 | rescue StandardError, LoadError => e 101 | e 102 | end 103 | end 104 | 105 | m.load_bundler! 106 | 107 | if m.invoked_as_script? 108 | load Gem.bin_path("bundler", "bundle") 109 | end 110 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # This file is the source Rails uses to define your schema when running `bin/rails 6 | # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to 7 | # be faster and is potentially less error prone than running all of your 8 | # migrations from scratch. Old migrations may fail to apply correctly if those 9 | # migrations use external dependencies or application code. 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema[7.1].define(version: 2023_10_07_145618) do 14 | # These are extensions that must be enabled in order to support this database 15 | enable_extension "plpgsql" 16 | 17 | create_table "contacts", force: :cascade do |t| 18 | t.string "name" 19 | t.string "email" 20 | t.text "message" 21 | t.datetime "created_at", null: false 22 | t.datetime "updated_at", null: false 23 | end 24 | 25 | create_table "features", force: :cascade do |t| 26 | t.string "name" 27 | t.datetime "created_at", null: false 28 | t.datetime "updated_at", null: false 29 | end 30 | 31 | create_table "properties", force: :cascade do |t| 32 | t.bigint "user_id", null: false 33 | t.bigint "type_offer_id", null: false 34 | t.bigint "type_property_id", null: false 35 | t.text "description" 36 | t.integer "area" 37 | t.decimal "price" 38 | t.datetime "created_at", null: false 39 | t.datetime "updated_at", null: false 40 | t.index ["type_offer_id"], name: "index_properties_on_type_offer_id" 41 | t.index ["type_property_id"], name: "index_properties_on_type_property_id" 42 | t.index ["user_id"], name: "index_properties_on_user_id" 43 | end 44 | 45 | create_table "property_features", force: :cascade do |t| 46 | t.bigint "property_id", null: false 47 | t.bigint "feature_id", null: false 48 | t.datetime "created_at", null: false 49 | t.datetime "updated_at", null: false 50 | t.index ["feature_id"], name: "index_property_features_on_feature_id" 51 | t.index ["property_id"], name: "index_property_features_on_property_id" 52 | end 53 | 54 | create_table "type_offers", force: :cascade do |t| 55 | t.string "name" 56 | t.datetime "created_at", null: false 57 | t.datetime "updated_at", null: false 58 | end 59 | 60 | create_table "type_properties", force: :cascade do |t| 61 | t.string "name" 62 | t.datetime "created_at", null: false 63 | t.datetime "updated_at", null: false 64 | end 65 | 66 | create_table "users", force: :cascade do |t| 67 | t.string "email", default: "", null: false 68 | t.string "encrypted_password", default: "", null: false 69 | t.string "reset_password_token" 70 | t.datetime "reset_password_sent_at" 71 | t.datetime "remember_created_at" 72 | t.string "name" 73 | t.bigint "phone" 74 | t.integer "role", default: 0 75 | t.datetime "created_at", null: false 76 | t.datetime "updated_at", null: false 77 | t.index ["email"], name: "index_users_on_email", unique: true 78 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true 79 | end 80 | 81 | add_foreign_key "properties", "type_offers" 82 | add_foreign_key "properties", "type_properties" 83 | add_foreign_key "properties", "users" 84 | add_foreign_key "property_features", "features" 85 | add_foreign_key "property_features", "properties" 86 | end 87 | -------------------------------------------------------------------------------- /config/locales/devise.en.yml: -------------------------------------------------------------------------------- 1 | # Additional translations at https://github.com/heartcombo/devise/wiki/I18n 2 | 3 | en: 4 | devise: 5 | confirmations: 6 | confirmed: "Your email address has been successfully confirmed." 7 | send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." 8 | send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes." 9 | failure: 10 | already_authenticated: "You are already signed in." 11 | inactive: "Your account is not activated yet." 12 | invalid: "Invalid %{authentication_keys} or password." 13 | locked: "Your account is locked." 14 | last_attempt: "You have one more attempt before your account is locked." 15 | not_found_in_database: "Invalid %{authentication_keys} or password." 16 | timeout: "Your session expired. Please sign in again to continue." 17 | unauthenticated: "You need to sign in or sign up before continuing." 18 | unconfirmed: "You have to confirm your email address before continuing." 19 | mailer: 20 | confirmation_instructions: 21 | subject: "Confirmation instructions" 22 | reset_password_instructions: 23 | subject: "Reset password instructions" 24 | unlock_instructions: 25 | subject: "Unlock instructions" 26 | email_changed: 27 | subject: "Email Changed" 28 | password_change: 29 | subject: "Password Changed" 30 | omniauth_callbacks: 31 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"." 32 | success: "Successfully authenticated from %{kind} account." 33 | passwords: 34 | no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." 35 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." 36 | send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." 37 | updated: "Your password has been changed successfully. You are now signed in." 38 | updated_not_active: "Your password has been changed successfully." 39 | registrations: 40 | destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." 41 | signed_up: "Welcome! You have signed up successfully." 42 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." 43 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." 44 | signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." 45 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address." 46 | updated: "Your account has been updated successfully." 47 | updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again." 48 | sessions: 49 | signed_in: "Signed in successfully." 50 | signed_out: "Signed out successfully." 51 | already_signed_out: "Signed out successfully." 52 | unlocks: 53 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." 54 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." 55 | unlocked: "Your account has been unlocked successfully. Please sign in to continue." 56 | errors: 57 | messages: 58 | already_confirmed: "was already confirmed, please try signing in" 59 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" 60 | expired: "has expired, please request a new one" 61 | not_found: "not found" 62 | not_locked: "was not locked" 63 | not_saved: 64 | one: "1 error prohibited this %{resource} from being saved:" 65 | other: "%{count} errors prohibited this %{resource} from being saved:" 66 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | Rails.application.configure do 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # Code is not reloaded between requests. 7 | config.enable_reloading = false 8 | 9 | # Eager load code on boot. This eager loads most of Rails and 10 | # your application in memory, allowing both threaded web servers 11 | # and those relying on copy on write to perform better. 12 | # Rake tasks automatically ignore this option for performance. 13 | config.eager_load = true 14 | 15 | # Full error reports are disabled and caching is turned on. 16 | config.consider_all_requests_local = false 17 | config.action_controller.perform_caching = true 18 | 19 | # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment 20 | # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). 21 | # config.require_master_key = true 22 | 23 | # Enable static file serving from the `/public` folder (turn off if using NGINX/Apache for it). 24 | config.public_file_server.enabled = true 25 | 26 | # Compress CSS using a preprocessor. 27 | # config.assets.css_compressor = :sass 28 | 29 | # Do not fallback to assets pipeline if a precompiled asset is missed. 30 | config.assets.compile = false 31 | 32 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 33 | # config.asset_host = "http://assets.example.com" 34 | 35 | # Specifies the header that your server uses for sending files. 36 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache 37 | # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX 38 | 39 | # Store uploaded files on the local file system (see config/storage.yml for options). 40 | config.active_storage.service = :local 41 | 42 | # Mount Action Cable outside main process or domain. 43 | # config.action_cable.mount_path = nil 44 | # config.action_cable.url = "wss://example.com/cable" 45 | # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] 46 | 47 | # Assume all access to the app is happening through a SSL-terminating reverse proxy. 48 | # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. 49 | # config.assume_ssl = true 50 | 51 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 52 | config.force_ssl = true 53 | 54 | # Log to STDOUT by default 55 | config.logger = ActiveSupport::Logger.new(STDOUT) 56 | .tap { |logger| logger.formatter = ::Logger::Formatter.new } 57 | .then { |logger| ActiveSupport::TaggedLogging.new(logger) } 58 | 59 | # Prepend all log lines with the following tags. 60 | config.log_tags = [ :request_id ] 61 | 62 | # Info include generic and useful information about system operation, but avoids logging too much 63 | # information to avoid inadvertent exposure of personally identifiable information (PII). If you 64 | # want to log everything, set the level to "debug". 65 | config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") 66 | 67 | # Use a different cache store in production. 68 | # config.cache_store = :mem_cache_store 69 | 70 | # Use a real queuing backend for Active Job (and separate queues per environment). 71 | # config.active_job.queue_adapter = :resque 72 | # config.active_job.queue_name_prefix = "inforcap_house_production" 73 | 74 | config.action_mailer.perform_caching = false 75 | 76 | # Ignore bad email addresses and do not raise email delivery errors. 77 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 78 | # config.action_mailer.raise_delivery_errors = false 79 | 80 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 81 | # the I18n.default_locale when a translation cannot be found). 82 | config.i18n.fallbacks = true 83 | 84 | # Don't log any deprecations. 85 | config.active_support.report_deprecations = false 86 | 87 | # Do not dump schema after migrations. 88 | config.active_record.dump_schema_after_migration = false 89 | 90 | # Enable DNS rebinding protection and other `Host` header attacks. 91 | # config.hosts = [ 92 | # "example.com", # Allow requests from example.com 93 | # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` 94 | # ] 95 | # Skip DNS rebinding protection for the default health check endpoint. 96 | # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } 97 | end 98 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Reforzamiento Inforcap Ruby on Rails - Proyecto InforcapHouse 2 | 3 | Este proyecto hace parte de un reforzamiento dado a los estudiantes de Inforcap, es una guía paso a paso para crear proyectos tipo MVP (Producto Mínimo Viable) haciendo uso del framework Ruby on Rails. El objetivo principal es repasar los conceptos básicos del framework, hacer uso de las mejores prácticas y crear un producto mínimo viable. 4 | 5 | Realizaremos el sitio web de una empresa dedicada a catalogar inmuebles para su compra y venta, donde se pueden visualizar los inmuebles y los usuarios pueden dejar sus reseñas 6 | 7 | ## Descripción 8 | 9 | Este proyecto estaría dirigido a personas que quieran aprender a crear aplicaciones web con Ruby on Rails, desde cero, hasta llegar a un producto mínimo viable. Si ya tienes conocimientos previos de Ruby on Rails, sería un buen repaso de los conceptos básicos y una buena práctica para mejorar tus habilidades. El proyecto se divide en las siguientes etapas: 10 | 11 | - [x] Etapa 1: Creación del proyecto 12 | - [x] Etapa 2: Generar Vistas estaticas 13 | - [x] Etapa 3: Generar Modelos de referencia 14 | - [x] Etapa 4: Integrar Autenticación de usuarios 15 | - [x] Etapa 5: Generar Scaffold de los inmuebles 16 | - [x] Etapa 6: Integrar ActiveStorage y relaciones polimorficas 17 | - [x] Etapa 7: Aplicar estilos a las vistas 18 | - [x] Etapa 8: Solicitar inmuebles 19 | 20 | ### El proyecto esta desarrollado siguiendo la siguiente premisa 21 | 22 | **InforcapHouse** es una empresa que esta incursionando en la venta de inmuebles, inicialmente publicaban los inmuebles en grupos de facebook o en instagram y están satisfechos con ambas plataformas 🖥️🛍️. Sin embargo, están buscando expandirse y crear su propia presencia en línea a través de un sitio web. 23 | 24 | El principal problema que enfrentan es la necesidad de una plataforma confiable y estable que cumpla con todos sus requerimientos: 25 | 26 | - Paginas estaticas, Inicio, terminos legales. 27 | - Formulario de contacto. 28 | - Autenticación de usuarios, 2 roles de usuario (Admin, User) 29 | - Inmueble con la siguiente información; Tipo de inmueble, tipo de oferta, descripción del inmueble, area, precio, caracteristicas (Estas deben poder seleccionar una o multiples), Foto e información de contacto. 30 | 31 | Aquí es donde entras tú 😊. Tu desafío es presentar una propuesta de desarrollo que sea competitiva, destacando entre otras empresas y profesionales. Presentas una propuesta económica atractiva con un presupuesto justo, lo que te permite obtener una ganancia 💰, ofreciendo un excelente plazo de entrega. Lo más destacado de tu propuesta es el desarrollo de un MVP utilizando el Design Thinking y sus diversas etapas. La cereza en el pastel 🍒 es tu promesa de un tiempo de desarrollo de solo 4 horas para el desarrollo del prototipado. 32 | 33 | El cliente toma la decisión y... ¡Felicidades! 🎉 Has ganado el proyecto. Recibes un anticipo y ahora puedes empezar a trabajar en el proyecto. Recuerda, necesitas tener conocimientos previos de frontend (HTML, CSS, JavaScript, Bootstrap) y backend (PostgreSQL, Ruby, Ruby on Rails, Heroku) para llevar a cabo este proyecto. ¡Vamos a empezar! 💪🚀 34 | 35 | ## Visuales 36 | 37 | Capturas de pantalla, videos o GIFs que demuestran lo que hace el proyecto y cómo usarlo. 38 | 39 | ## Empezando 🚀 40 | 41 | Estas instrucciones te guiarán para obtener una copia de este proyecto en funcionamiento en tu máquina local para propósitos de desarrollo y pruebas. Ten en cuenta que el proyecto está en desarrollo y puede tener cambios en el futuro, por lo que se recomienda clonar el proyecto en lugar de descargarlo, para que puedas obtener las actualizaciones más recientes. También puedes hacer un fork del proyecto para contribuir con el desarrollo del mismo y estar al tanto de las actualizaciones. 42 | 43 | Para obtener una copia local en funcionamiento, sigue estos pasos. 44 | 45 | ```bash 46 | git clone git@github.com:brayandiazc/InforcapHouse.git 47 | ``` 48 | 49 | Ingresa a la carpeta del proyecto 50 | 51 | ```bash 52 | cd InforcapHouse 53 | ``` 54 | 55 | Con estos simples pasos ya estas listo para comenzar a desarrollar. 56 | 57 | ### Prerrequisitos 📋 58 | 59 | Antes de comenzar, asegúrate de cumplir con los siguientes requisitos: 60 | 61 | - Sistema Operativo: Windows, Linux, macOS, WSL 62 | - Lenguaje de programación Ruby 3.2.2 63 | - Framework Ruby on Rails 7.1.0 64 | - Base de datos Postgresql 65 | 66 | Se recomienda usar un sistema unix-like (Linux, macOS, WSL) para el desarrollo de este proyecto. En caso de usar Windows, se recomienda usar WSL (Windows Subsystem for Linux) para el desarrollo de este proyecto. Si no se tiene instalado WSL, puedes seguir la siguiente guía de instalación: [Instalación de WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10) 67 | 68 | Si no tienes instalado Ruby y Ruby on Rails, puedes seguir la siguiente guía de instalación: [Instalación de Ruby](https://www.ruby-lang.org/es/documentation/installation/) 69 | 70 | Si no tienes instalado Postgresql, puedes seguir la siguiente guía de instalación: [Instalación de Postgresql](https://www.postgresql.org/download/) 71 | 72 | ### Instalación 🔧 73 | 74 | Para poder ejecutar el proyecto después de haberlo clonado, debes ejecutar los siguientes pasos en tu terminal: 75 | 76 | ```bash 77 | bundle install 78 | ``` 79 | 80 | ```bash 81 | rails db:create 82 | ``` 83 | 84 | ```bash 85 | rails db:migrate 86 | ``` 87 | 88 | ```bash 89 | rails db:seed 90 | ``` 91 | 92 | ```bash 93 | rails s 94 | ``` 95 | 96 | ## Despliegue 📦 97 | 98 | Para el despliegue hare uso de [Heroku](https://www.heroku.com/), una plataforma como servicio de computación en la nube que soporta distintos lenguajes de programación. Las instrucciones para el despliegue se encuentran en la siguiente archivo: [Despliegue](assets/README.md) 99 | 100 | ## Construido Con 🛠️ 101 | 102 | Herramientas utilizadas para crear el proyecto: 103 | 104 | - [Ruby](https://www.ruby-lang.org/es/) - El lenguaje utilizado 105 | - [Ruby on Rails](https://rubyonrails.org) - El framework web utilizado 106 | - [Ruby gems](https://rubygems.org) - Gestión de dependencias 107 | - [Postgresql](https://www.postgresql.org) - Sistema de base de datos 108 | - [Bootstrap](https://getbootstrap.com) - Framework de CSS 109 | 110 | ## Soporte 111 | 112 | Si tienes algún problema o sugerencia, por favor abre un problema [aquí](https://github.com/brayandiazc/Aprendiendo-RubyOnRails/issues). 113 | 114 | ## Roadmap 115 | 116 | Ideas, mejoras planificadas y actualizaciones futuras 117 | 118 | para el proyecto actual. 119 | 120 | ## Versionado 📌 121 | 122 | Estoy usando [Git](https://git-scm.com) para el versionado. 123 | 124 | ## Autor ✒️ 125 | 126 | - [Brayan Diaz C](https://github.com/brayandiazc) 127 | 128 | ## Licencia 📄 129 | 130 | Este proyecto está bajo la Licencia MIT - ve el archivo [LICENSE.md](LICENSE.md) para detalles 131 | 132 | ## Expresiones de Gratitud 🎁 133 | 134 | Si encontraste cualquier valor en este proyecto o quieres contribuir, aquí está lo que puedes hacer: 135 | 136 | - Comparte este proyecto con otros 137 | - haz un fork de este proyecto 138 | - Deja una estrella ⭐️ 139 | - Inicia un nuevo issue o contribuye con un PR 140 | - Muestra tu agradecimiento diciendo gracias en un nuevo Issue. 141 | 142 | ⌨️ con ❤️ por [Brayan Diaz C](https://github.com/brayandiazc) 😊 143 | 144 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (7.1.0) 5 | actionpack (= 7.1.0) 6 | activesupport (= 7.1.0) 7 | nio4r (~> 2.0) 8 | websocket-driver (>= 0.6.1) 9 | zeitwerk (~> 2.6) 10 | actionmailbox (7.1.0) 11 | actionpack (= 7.1.0) 12 | activejob (= 7.1.0) 13 | activerecord (= 7.1.0) 14 | activestorage (= 7.1.0) 15 | activesupport (= 7.1.0) 16 | mail (>= 2.7.1) 17 | net-imap 18 | net-pop 19 | net-smtp 20 | actionmailer (7.1.0) 21 | actionpack (= 7.1.0) 22 | actionview (= 7.1.0) 23 | activejob (= 7.1.0) 24 | activesupport (= 7.1.0) 25 | mail (~> 2.5, >= 2.5.4) 26 | net-imap 27 | net-pop 28 | net-smtp 29 | rails-dom-testing (~> 2.2) 30 | actionpack (7.1.0) 31 | actionview (= 7.1.0) 32 | activesupport (= 7.1.0) 33 | nokogiri (>= 1.8.5) 34 | rack (>= 2.2.4) 35 | rack-session (>= 1.0.1) 36 | rack-test (>= 0.6.3) 37 | rails-dom-testing (~> 2.2) 38 | rails-html-sanitizer (~> 1.6) 39 | actiontext (7.1.0) 40 | actionpack (= 7.1.0) 41 | activerecord (= 7.1.0) 42 | activestorage (= 7.1.0) 43 | activesupport (= 7.1.0) 44 | globalid (>= 0.6.0) 45 | nokogiri (>= 1.8.5) 46 | actionview (7.1.0) 47 | activesupport (= 7.1.0) 48 | builder (~> 3.1) 49 | erubi (~> 1.11) 50 | rails-dom-testing (~> 2.2) 51 | rails-html-sanitizer (~> 1.6) 52 | activejob (7.1.0) 53 | activesupport (= 7.1.0) 54 | globalid (>= 0.3.6) 55 | activemodel (7.1.0) 56 | activesupport (= 7.1.0) 57 | activerecord (7.1.0) 58 | activemodel (= 7.1.0) 59 | activesupport (= 7.1.0) 60 | timeout (>= 0.4.0) 61 | activestorage (7.1.0) 62 | actionpack (= 7.1.0) 63 | activejob (= 7.1.0) 64 | activerecord (= 7.1.0) 65 | activesupport (= 7.1.0) 66 | marcel (~> 1.0) 67 | activesupport (7.1.0) 68 | base64 69 | bigdecimal 70 | concurrent-ruby (~> 1.0, >= 1.0.2) 71 | connection_pool (>= 2.2.5) 72 | drb 73 | i18n (>= 1.6, < 2) 74 | minitest (>= 5.1) 75 | mutex_m 76 | tzinfo (~> 2.0) 77 | addressable (2.8.5) 78 | public_suffix (>= 2.0.2, < 6.0) 79 | annotate (3.2.0) 80 | activerecord (>= 3.2, < 8.0) 81 | rake (>= 10.4, < 14.0) 82 | base64 (0.1.1) 83 | bcrypt (3.1.19) 84 | bigdecimal (3.1.4) 85 | bindex (0.8.1) 86 | bootsnap (1.16.0) 87 | msgpack (~> 1.2) 88 | builder (3.2.4) 89 | capybara (3.39.2) 90 | addressable 91 | matrix 92 | mini_mime (>= 0.1.3) 93 | nokogiri (~> 1.8) 94 | rack (>= 1.6.0) 95 | rack-test (>= 0.6.3) 96 | regexp_parser (>= 1.5, < 3.0) 97 | xpath (~> 3.2) 98 | concurrent-ruby (1.2.2) 99 | connection_pool (2.4.1) 100 | crass (1.0.6) 101 | date (3.3.3) 102 | debug (1.8.0) 103 | irb (>= 1.5.0) 104 | reline (>= 0.3.1) 105 | devise (4.9.2) 106 | bcrypt (~> 3.0) 107 | orm_adapter (~> 0.1) 108 | railties (>= 4.1.0) 109 | responders 110 | warden (~> 1.2.3) 111 | drb (2.1.1) 112 | ruby2_keywords 113 | erubi (1.12.0) 114 | faker (3.2.1) 115 | i18n (>= 1.8.11, < 2) 116 | globalid (1.2.1) 117 | activesupport (>= 6.1) 118 | i18n (1.14.1) 119 | concurrent-ruby (~> 1.0) 120 | importmap-rails (1.2.1) 121 | actionpack (>= 6.0.0) 122 | railties (>= 6.0.0) 123 | io-console (0.6.0) 124 | irb (1.8.1) 125 | rdoc 126 | reline (>= 0.3.8) 127 | jbuilder (2.11.5) 128 | actionview (>= 5.0.0) 129 | activesupport (>= 5.0.0) 130 | loofah (2.21.3) 131 | crass (~> 1.0.2) 132 | nokogiri (>= 1.12.0) 133 | mail (2.8.1) 134 | mini_mime (>= 0.1.1) 135 | net-imap 136 | net-pop 137 | net-smtp 138 | marcel (1.0.2) 139 | matrix (0.4.2) 140 | mini_mime (1.1.5) 141 | minitest (5.20.0) 142 | msgpack (1.7.2) 143 | mutex_m (0.1.2) 144 | net-imap (0.4.0) 145 | date 146 | net-protocol 147 | net-pop (0.1.2) 148 | net-protocol 149 | net-protocol (0.2.1) 150 | timeout 151 | net-smtp (0.4.0) 152 | net-protocol 153 | nio4r (2.5.9) 154 | nokogiri (1.15.4-x86_64-linux) 155 | racc (~> 1.4) 156 | orm_adapter (0.5.0) 157 | pagy (6.1.0) 158 | pg (1.5.4) 159 | psych (5.1.0) 160 | stringio 161 | public_suffix (5.0.3) 162 | puma (6.4.0) 163 | nio4r (~> 2.0) 164 | racc (1.7.1) 165 | rack (3.0.8) 166 | rack-session (2.0.0) 167 | rack (>= 3.0.0) 168 | rack-test (2.1.0) 169 | rack (>= 1.3) 170 | rackup (2.1.0) 171 | rack (>= 3) 172 | webrick (~> 1.8) 173 | rails (7.1.0) 174 | actioncable (= 7.1.0) 175 | actionmailbox (= 7.1.0) 176 | actionmailer (= 7.1.0) 177 | actionpack (= 7.1.0) 178 | actiontext (= 7.1.0) 179 | actionview (= 7.1.0) 180 | activejob (= 7.1.0) 181 | activemodel (= 7.1.0) 182 | activerecord (= 7.1.0) 183 | activestorage (= 7.1.0) 184 | activesupport (= 7.1.0) 185 | bundler (>= 1.15.0) 186 | railties (= 7.1.0) 187 | rails-dom-testing (2.2.0) 188 | activesupport (>= 5.0.0) 189 | minitest 190 | nokogiri (>= 1.6) 191 | rails-html-sanitizer (1.6.0) 192 | loofah (~> 2.21) 193 | nokogiri (~> 1.14) 194 | railties (7.1.0) 195 | actionpack (= 7.1.0) 196 | activesupport (= 7.1.0) 197 | irb 198 | rackup (>= 1.0.0) 199 | rake (>= 12.2) 200 | thor (~> 1.0, >= 1.2.2) 201 | zeitwerk (~> 2.6) 202 | rake (13.0.6) 203 | rdoc (6.5.0) 204 | psych (>= 4.0.0) 205 | regexp_parser (2.8.1) 206 | reline (0.3.9) 207 | io-console (~> 0.5) 208 | responders (3.1.0) 209 | actionpack (>= 5.2) 210 | railties (>= 5.2) 211 | rexml (3.2.6) 212 | ruby2_keywords (0.0.5) 213 | rubyzip (2.3.2) 214 | selenium-webdriver (4.13.1) 215 | rexml (~> 3.2, >= 3.2.5) 216 | rubyzip (>= 1.2.2, < 3.0) 217 | websocket (~> 1.0) 218 | sprockets (4.2.1) 219 | concurrent-ruby (~> 1.0) 220 | rack (>= 2.2.4, < 4) 221 | sprockets-rails (3.4.2) 222 | actionpack (>= 5.2) 223 | activesupport (>= 5.2) 224 | sprockets (>= 3.0.0) 225 | stimulus-rails (1.2.2) 226 | railties (>= 6.0.0) 227 | stringio (3.0.8) 228 | thor (1.2.2) 229 | timeout (0.4.0) 230 | turbo-rails (1.4.0) 231 | actionpack (>= 6.0.0) 232 | activejob (>= 6.0.0) 233 | railties (>= 6.0.0) 234 | tzinfo (2.0.6) 235 | concurrent-ruby (~> 1.0) 236 | warden (1.2.9) 237 | rack (>= 2.0.9) 238 | web-console (4.2.1) 239 | actionview (>= 6.0.0) 240 | activemodel (>= 6.0.0) 241 | bindex (>= 0.4.0) 242 | railties (>= 6.0.0) 243 | webrick (1.8.1) 244 | websocket (1.2.10) 245 | websocket-driver (0.7.6) 246 | websocket-extensions (>= 0.1.0) 247 | websocket-extensions (0.1.5) 248 | xpath (3.2.0) 249 | nokogiri (~> 1.8) 250 | zeitwerk (2.6.12) 251 | 252 | PLATFORMS 253 | x86_64-linux 254 | 255 | DEPENDENCIES 256 | annotate (~> 3.2) 257 | bootsnap 258 | capybara 259 | debug 260 | devise (~> 4.9) 261 | faker (~> 3.2) 262 | importmap-rails 263 | jbuilder 264 | pagy (~> 6.1) 265 | pg (~> 1.1) 266 | puma (>= 5.0) 267 | rails (~> 7.1.0) 268 | selenium-webdriver 269 | sprockets-rails 270 | stimulus-rails 271 | turbo-rails 272 | tzinfo-data 273 | web-console 274 | 275 | RUBY VERSION 276 | ruby 3.2.2p53 277 | 278 | BUNDLED WITH 279 | 2.4.20 280 | -------------------------------------------------------------------------------- /config/initializers/devise.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Assuming you have not yet modified this file, each configuration option below 4 | # is set to its default value. Note that some are commented out while others 5 | # are not: uncommented lines are intended to protect your configuration from 6 | # breaking changes in upgrades (i.e., in the event that future versions of 7 | # Devise change the default values for those options). 8 | # 9 | # Use this hook to configure devise mailer, warden hooks and so forth. 10 | # Many of these configuration options can be set straight in your model. 11 | Devise.setup do |config| 12 | # The secret key used by Devise. Devise uses this key to generate 13 | # random tokens. Changing this key will render invalid all existing 14 | # confirmation, reset password and unlock tokens in the database. 15 | # Devise will use the `secret_key_base` as its `secret_key` 16 | # by default. You can change it below and use your own secret key. 17 | # config.secret_key = 'b50226fb9f712afa839319140cc916eacfff7ed6d4a600b5993880cbb58362d5bb4de34656fb36873e373e5c369dc6abb232af0a886a1bcd46912a43de2aad9f' 18 | 19 | # ==> Controller configuration 20 | # Configure the parent class to the devise controllers. 21 | # config.parent_controller = 'DeviseController' 22 | 23 | # ==> Mailer Configuration 24 | # Configure the e-mail address which will be shown in Devise::Mailer, 25 | # note that it will be overwritten if you use your own mailer class 26 | # with default "from" parameter. 27 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' 28 | 29 | # Configure the class responsible to send e-mails. 30 | # config.mailer = 'Devise::Mailer' 31 | 32 | # Configure the parent class responsible to send e-mails. 33 | # config.parent_mailer = 'ActionMailer::Base' 34 | 35 | # ==> ORM configuration 36 | # Load and configure the ORM. Supports :active_record (default) and 37 | # :mongoid (bson_ext recommended) by default. Other ORMs may be 38 | # available as additional gems. 39 | require 'devise/orm/active_record' 40 | 41 | # ==> Configuration for any authentication mechanism 42 | # Configure which keys are used when authenticating a user. The default is 43 | # just :email. You can configure it to use [:username, :subdomain], so for 44 | # authenticating a user, both parameters are required. Remember that those 45 | # parameters are used only when authenticating and not when retrieving from 46 | # session. If you need permissions, you should implement that in a before filter. 47 | # You can also supply a hash where the value is a boolean determining whether 48 | # or not authentication should be aborted when the value is not present. 49 | # config.authentication_keys = [:email] 50 | 51 | # Configure parameters from the request object used for authentication. Each entry 52 | # given should be a request method and it will automatically be passed to the 53 | # find_for_authentication method and considered in your model lookup. For instance, 54 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. 55 | # The same considerations mentioned for authentication_keys also apply to request_keys. 56 | # config.request_keys = [] 57 | 58 | # Configure which authentication keys should be case-insensitive. 59 | # These keys will be downcased upon creating or modifying a user and when used 60 | # to authenticate or find a user. Default is :email. 61 | config.case_insensitive_keys = [:email] 62 | 63 | # Configure which authentication keys should have whitespace stripped. 64 | # These keys will have whitespace before and after removed upon creating or 65 | # modifying a user and when used to authenticate or find a user. Default is :email. 66 | config.strip_whitespace_keys = [:email] 67 | 68 | # Tell if authentication through request.params is enabled. True by default. 69 | # It can be set to an array that will enable params authentication only for the 70 | # given strategies, for example, `config.params_authenticatable = [:database]` will 71 | # enable it only for database (email + password) authentication. 72 | # config.params_authenticatable = true 73 | 74 | # Tell if authentication through HTTP Auth is enabled. False by default. 75 | # It can be set to an array that will enable http authentication only for the 76 | # given strategies, for example, `config.http_authenticatable = [:database]` will 77 | # enable it only for database authentication. 78 | # For API-only applications to support authentication "out-of-the-box", you will likely want to 79 | # enable this with :database unless you are using a custom strategy. 80 | # The supported strategies are: 81 | # :database = Support basic authentication with authentication key + password 82 | # config.http_authenticatable = false 83 | 84 | # If 401 status code should be returned for AJAX requests. True by default. 85 | # config.http_authenticatable_on_xhr = true 86 | 87 | # The realm used in Http Basic Authentication. 'Application' by default. 88 | # config.http_authentication_realm = 'Application' 89 | 90 | # It will change confirmation, password recovery and other workflows 91 | # to behave the same regardless if the e-mail provided was right or wrong. 92 | # Does not affect registerable. 93 | # config.paranoid = true 94 | 95 | # By default Devise will store the user in session. You can skip storage for 96 | # particular strategies by setting this option. 97 | # Notice that if you are skipping storage for all authentication paths, you 98 | # may want to disable generating routes to Devise's sessions controller by 99 | # passing skip: :sessions to `devise_for` in your config/routes.rb 100 | config.skip_session_storage = [:http_auth] 101 | 102 | # By default, Devise cleans up the CSRF token on authentication to 103 | # avoid CSRF token fixation attacks. This means that, when using AJAX 104 | # requests for sign in and sign up, you need to get a new CSRF token 105 | # from the server. You can disable this option at your own risk. 106 | # config.clean_up_csrf_token_on_authentication = true 107 | 108 | # When false, Devise will not attempt to reload routes on eager load. 109 | # This can reduce the time taken to boot the app but if your application 110 | # requires the Devise mappings to be loaded during boot time the application 111 | # won't boot properly. 112 | # config.reload_routes = true 113 | 114 | # ==> Configuration for :database_authenticatable 115 | # For bcrypt, this is the cost for hashing the password and defaults to 12. If 116 | # using other algorithms, it sets how many times you want the password to be hashed. 117 | # The number of stretches used for generating the hashed password are stored 118 | # with the hashed password. This allows you to change the stretches without 119 | # invalidating existing passwords. 120 | # 121 | # Limiting the stretches to just one in testing will increase the performance of 122 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use 123 | # a value less than 10 in other environments. Note that, for bcrypt (the default 124 | # algorithm), the cost increases exponentially with the number of stretches (e.g. 125 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). 126 | config.stretches = Rails.env.test? ? 1 : 12 127 | 128 | # Set up a pepper to generate the hashed password. 129 | # config.pepper = 'c2bd16bc8a05157f522b28cf2ee7dc214e19b9495de6ba64f170a9fe9361726a4d05fe9d4b7d5f61c3aca65e3f9ac20f6eae4717b470509a08fdcaa819c0b145' 130 | 131 | # Send a notification to the original email when the user's email is changed. 132 | # config.send_email_changed_notification = false 133 | 134 | # Send a notification email when the user's password is changed. 135 | # config.send_password_change_notification = false 136 | 137 | # ==> Configuration for :confirmable 138 | # A period that the user is allowed to access the website even without 139 | # confirming their account. For instance, if set to 2.days, the user will be 140 | # able to access the website for two days without confirming their account, 141 | # access will be blocked just in the third day. 142 | # You can also set it to nil, which will allow the user to access the website 143 | # without confirming their account. 144 | # Default is 0.days, meaning the user cannot access the website without 145 | # confirming their account. 146 | # config.allow_unconfirmed_access_for = 2.days 147 | 148 | # A period that the user is allowed to confirm their account before their 149 | # token becomes invalid. For example, if set to 3.days, the user can confirm 150 | # their account within 3 days after the mail was sent, but on the fourth day 151 | # their account can't be confirmed with the token any more. 152 | # Default is nil, meaning there is no restriction on how long a user can take 153 | # before confirming their account. 154 | # config.confirm_within = 3.days 155 | 156 | # If true, requires any email changes to be confirmed (exactly the same way as 157 | # initial account confirmation) to be applied. Requires additional unconfirmed_email 158 | # db field (see migrations). Until confirmed, new email is stored in 159 | # unconfirmed_email column, and copied to email column on successful confirmation. 160 | config.reconfirmable = true 161 | 162 | # Defines which key will be used when confirming an account 163 | # config.confirmation_keys = [:email] 164 | 165 | # ==> Configuration for :rememberable 166 | # The time the user will be remembered without asking for credentials again. 167 | # config.remember_for = 2.weeks 168 | 169 | # Invalidates all the remember me tokens when the user signs out. 170 | config.expire_all_remember_me_on_sign_out = true 171 | 172 | # If true, extends the user's remember period when remembered via cookie. 173 | # config.extend_remember_period = false 174 | 175 | # Options to be passed to the created cookie. For instance, you can set 176 | # secure: true in order to force SSL only cookies. 177 | # config.rememberable_options = {} 178 | 179 | # ==> Configuration for :validatable 180 | # Range for password length. 181 | config.password_length = 6..128 182 | 183 | # Email regex used to validate email formats. It simply asserts that 184 | # one (and only one) @ exists in the given string. This is mainly 185 | # to give user feedback and not to assert the e-mail validity. 186 | config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ 187 | 188 | # ==> Configuration for :timeoutable 189 | # The time you want to timeout the user session without activity. After this 190 | # time the user will be asked for credentials again. Default is 30 minutes. 191 | # config.timeout_in = 30.minutes 192 | 193 | # ==> Configuration for :lockable 194 | # Defines which strategy will be used to lock an account. 195 | # :failed_attempts = Locks an account after a number of failed attempts to sign in. 196 | # :none = No lock strategy. You should handle locking by yourself. 197 | # config.lock_strategy = :failed_attempts 198 | 199 | # Defines which key will be used when locking and unlocking an account 200 | # config.unlock_keys = [:email] 201 | 202 | # Defines which strategy will be used to unlock an account. 203 | # :email = Sends an unlock link to the user email 204 | # :time = Re-enables login after a certain amount of time (see :unlock_in below) 205 | # :both = Enables both strategies 206 | # :none = No unlock strategy. You should handle unlocking by yourself. 207 | # config.unlock_strategy = :both 208 | 209 | # Number of authentication tries before locking an account if lock_strategy 210 | # is failed attempts. 211 | # config.maximum_attempts = 20 212 | 213 | # Time interval to unlock the account if :time is enabled as unlock_strategy. 214 | # config.unlock_in = 1.hour 215 | 216 | # Warn on the last attempt before the account is locked. 217 | # config.last_attempt_warning = true 218 | 219 | # ==> Configuration for :recoverable 220 | # 221 | # Defines which key will be used when recovering the password for an account 222 | # config.reset_password_keys = [:email] 223 | 224 | # Time interval you can reset your password with a reset password key. 225 | # Don't put a too small interval or your users won't have the time to 226 | # change their passwords. 227 | config.reset_password_within = 6.hours 228 | 229 | # When set to false, does not sign a user in automatically after their password is 230 | # reset. Defaults to true, so a user is signed in automatically after a reset. 231 | # config.sign_in_after_reset_password = true 232 | 233 | # ==> Configuration for :encryptable 234 | # Allow you to use another hashing or encryption algorithm besides bcrypt (default). 235 | # You can use :sha1, :sha512 or algorithms from others authentication tools as 236 | # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20 237 | # for default behavior) and :restful_authentication_sha1 (then you should set 238 | # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper). 239 | # 240 | # Require the `devise-encryptable` gem when using anything other than bcrypt 241 | # config.encryptor = :sha512 242 | 243 | # ==> Scopes configuration 244 | # Turn scoped views on. Before rendering "sessions/new", it will first check for 245 | # "users/sessions/new". It's turned off by default because it's slower if you 246 | # are using only default views. 247 | config.scoped_views = true 248 | 249 | # Configure the default scope given to Warden. By default it's the first 250 | # devise role declared in your routes (usually :user). 251 | # config.default_scope = :user 252 | 253 | # Set this configuration to false if you want /users/sign_out to sign out 254 | # only the current scope. By default, Devise signs out all scopes. 255 | # config.sign_out_all_scopes = true 256 | 257 | # ==> Navigation configuration 258 | # Lists the formats that should be treated as navigational. Formats like 259 | # :html should redirect to the sign in page when the user does not have 260 | # access, but formats like :xml or :json, should return 401. 261 | # 262 | # If you have any extra navigational formats, like :iphone or :mobile, you 263 | # should add them to the navigational formats lists. 264 | # 265 | # The "*/*" below is required to match Internet Explorer requests. 266 | config.navigational_formats = ['*/*', :html, :turbo_stream] 267 | 268 | # The default HTTP method used to sign out a resource. Default is :delete. 269 | config.sign_out_via = :delete 270 | 271 | # ==> OmniAuth 272 | # Add a new OmniAuth provider. Check the wiki for more information on setting 273 | # up on your models and hooks. 274 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' 275 | 276 | # ==> Warden configuration 277 | # If you want to use other strategies, that are not supported by Devise, or 278 | # change the failure app, you can configure them inside the config.warden block. 279 | # 280 | # config.warden do |manager| 281 | # manager.intercept_401 = false 282 | # manager.default_strategies(scope: :user).unshift :some_external_strategy 283 | # end 284 | 285 | # ==> Mountable engine configurations 286 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine 287 | # is mountable, there are some extra configurations to be taken into account. 288 | # The following options are available, assuming the engine is mounted as: 289 | # 290 | # mount MyEngine, at: '/my_engine' 291 | # 292 | # The router that invoked `devise_for`, in the example above, would be: 293 | # config.router_name = :my_engine 294 | # 295 | # When using OmniAuth, Devise cannot automatically set OmniAuth path, 296 | # so you need to do it manually. For the users scope, it would be: 297 | # config.omniauth_path_prefix = '/my_engine/users/auth' 298 | 299 | # ==> Hotwire/Turbo configuration 300 | # When using Devise with Hotwire/Turbo, the http status for error responses 301 | # and some redirects must match the following. The default in Devise for existing 302 | # apps is `200 OK` and `302 Found respectively`, but new apps are generated with 303 | # these new defaults that match Hotwire/Turbo behavior. 304 | # Note: These might become the new default in future versions of Devise. 305 | config.responder.error_status = :unprocessable_entity 306 | config.responder.redirect_status = :see_other 307 | 308 | # ==> Configuration for :registerable 309 | 310 | # When set to false, does not sign a user in automatically after their password is 311 | # changed. Defaults to true, so a user is signed in automatically after changing a password. 312 | # config.sign_in_after_change_password = true 313 | end 314 | --------------------------------------------------------------------------------