Share your bed with the community. Be fun and sexy !
2 |
3 |
4 |
5 |
6 |
Add my Bed
7 |
8 | <%= simple_form_for @bed do |f| %>
9 | <%= f.error_notification %>
10 | <%= f.input :title, placeholder: "Warm bed with silk sheets", :label_html => { :class => "label-css"} %>
11 | <%= f.input :address, label: "My lovely nest is located at this address", placeholder: "36 avenue du calin" %>
12 | <%= f.input :city, placeholder: "Bisouville" %>
13 | <%= f.input :country, priority: ["France"] %>
14 | <%= f.input :description, label: "A sexy description for a warm bed", placeholder: "I live in a cosy house in the countryside. I love hugs and spending the night with strangers. My bed has high tech silk sheets and a warm pink blanket. Don't hesitate: Book a night (or more)" %>
15 | <%= f.input :price, label: "Price per night in €", placeholder: "48" %>
16 |
17 | <%= f.input :photo, as: :attachinary, label: "Choose a nice picture for your bed" %>
18 |
19 |
20 |
EQUIPEMENTS
21 |
22 | <%= f.input :pillow, as: :boolean, label: "Providing a pillow?" %>
23 | <%= f.input :breakfast, as: :boolean, label: "Serving breakfast in bed?" %>
24 | <%= f.input :blanket_type, collection: Bed::BLANKET, label: "What kind of blanket are you providing?" %>
25 |
26 |
27 | <%= f.button :submit, "Share my bed", class: "btn btn-danger btn-lg"%>
28 |
29 | <% end %>
30 |
85 |
86 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/bin/figaro:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 | #
4 | # This file was generated by Bundler.
5 | #
6 | # The application 'figaro' is installed as part of a gem, and
7 | # this file is here to facilitate running it.
8 | #
9 |
10 | require "pathname"
11 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12 | Pathname.new(__FILE__).realpath)
13 |
14 | require "rubygems"
15 | require "bundler/setup"
16 |
17 | load Gem.bin_path("figaro", "figaro")
18 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | APP_PATH = File.expand_path('../config/application', __dir__)
8 | require_relative '../config/boot'
9 | require 'rails/commands'
10 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | require_relative '../config/boot'
8 | require 'rake'
9 | Rake.application.run
10 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a starting point to setup your application.
15 | # Add necessary setup steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system('bundle check') || system!('bundle install')
20 |
21 | # puts "\n== Copying sample files =="
22 | # unless File.exist?('config/database.yml')
23 | # cp 'config/database.yml.sample', 'config/database.yml'
24 | # end
25 |
26 | puts "\n== Preparing database =="
27 | system! 'bin/rails db:setup'
28 |
29 | puts "\n== Removing old logs and tempfiles =="
30 | system! 'bin/rails log:clear tmp:clear'
31 |
32 | puts "\n== Restarting application server =="
33 | system! 'bin/rails restart'
34 | end
35 |
--------------------------------------------------------------------------------
/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This file loads spring without using Bundler, in order to be fast.
4 | # It gets overwritten when you run the `spring binstub` command.
5 |
6 | unless defined?(Spring)
7 | require 'rubygems'
8 | require 'bundler'
9 |
10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" }
12 | if spring
13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
14 | gem 'spring', spring.version
15 | require 'spring/binstub'
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/bin/update:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a way to update your development environment automatically.
15 | # Add necessary update steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system('bundle check') || system!('bundle install')
20 |
21 | puts "\n== Updating database =="
22 | system! 'bin/rails db:migrate'
23 |
24 | puts "\n== Removing old logs and tempfiles =="
25 | system! 'bin/rails log:clear tmp:clear'
26 |
27 | puts "\n== Restarting application server =="
28 | system! 'bin/rails restart'
29 | end
30 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require_relative 'boot'
2 |
3 | require "rails"
4 | # Pick the frameworks you want:
5 | require "active_model/railtie"
6 | require "active_job/railtie"
7 | require "active_record/railtie"
8 | require "action_controller/railtie"
9 | require "action_mailer/railtie"
10 | require "action_view/railtie"
11 | require "action_cable/engine"
12 | require "sprockets/railtie"
13 | # require "rails/test_unit/railtie"
14 | require "attachinary/orm/active_record"
15 |
16 | # Require the gems listed in Gemfile, including any gems
17 | # you've limited to :test, :development, or :production.
18 | Bundler.require(*Rails.groups)
19 |
20 | module RailsAirbnbClone
21 | class Application < Rails::Application
22 | config.generators do |generate|
23 | generate.assets false
24 | end
25 |
26 | # Settings in config/environments/* take precedence over those specified here.
27 | # Application configuration should go into files in config/initializers
28 | # -- all .rb files in that directory are automatically loaded.
29 | end
30 | end
31 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/config/cable.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: async
3 |
4 | test:
5 | adapter: async
6 |
7 | production:
8 | adapter: redis
9 | url: redis://localhost:6379/1
10 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # PostgreSQL. Versions 9.1 and up are supported.
2 | #
3 | # Install the pg driver:
4 | # gem install pg
5 | # On OS X with Homebrew:
6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7 | # On OS X with MacPorts:
8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9 | # On Windows:
10 | # gem install pg
11 | # Choose the win32 build.
12 | # Install PostgreSQL and put its /bin directory on your path.
13 | #
14 | # Configure Using Gemfile
15 | # gem 'pg'
16 | #
17 | default: &default
18 | adapter: postgresql
19 | encoding: unicode
20 | # For details on connection pooling, see rails configuration guide
21 | # http://guides.rubyonrails.org/configuring.html#database-pooling
22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23 |
24 | development:
25 | <<: *default
26 | database: rails-airbnb-clone_development
27 |
28 | # The specified database role being used to connect to postgres.
29 | # To create additional roles in postgres see `$ createuser --help`.
30 | # When left blank, postgres will use the default role. This is
31 | # the same name as the operating system user that initialized the database.
32 | #username: rails-airbnb-clone
33 |
34 | # The password associated with the postgres role (username).
35 | #password:
36 |
37 | # Connect on a TCP socket. Omitted by default since the client uses a
38 | # domain socket that doesn't need configuration. Windows does not have
39 | # domain sockets, so uncomment these lines.
40 | host: localhost
41 |
42 | # The TCP port the server listens on. Defaults to 5432.
43 | # If your server runs on a different port number, change accordingly.
44 | #port: 5432
45 |
46 | # Schema search path. The server defaults to $user,public
47 | #schema_search_path: myapp,sharedapp,public
48 |
49 | # Minimum log levels, in increasing order:
50 | # debug5, debug4, debug3, debug2, debug1,
51 | # log, notice, warning, error, fatal, and panic
52 | # Defaults to warning.
53 | #min_messages: notice
54 |
55 | # Warning: The database defined as "test" will be erased and
56 | # re-generated from your development database when you run "rake".
57 | # Do not set this db to the same as development or production.
58 | test:
59 | <<: *default
60 | database: rails-airbnb-clone_test
61 |
62 | # As with config/secrets.yml, you never want to store sensitive information,
63 | # like your database password, in your source code. If your source code is
64 | # ever seen by anyone, they now have access to your database.
65 | #
66 | # Instead, provide the password as a unix environment variable when you boot
67 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
68 | # for a full rundown on how to provide these environment variables in a
69 | # production deployment.
70 | #
71 | # On Heroku and other platform providers, you may have a full connection URL
72 | # available as an environment variable. For example:
73 | #
74 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
75 | #
76 | # You can use this database configuration with:
77 | #
78 | # production:
79 | # url: <%= ENV['DATABASE_URL'] %>
80 | #
81 | production:
82 | <<: *default
83 | database: rails-airbnb-clone_production
84 | username: rails-airbnb-clone
85 | password: <%= ENV['RAILS-AIRBNB-CLONE_DATABASE_PASSWORD'] %>
86 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require_relative 'application'
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Do not eager load code on boot.
10 | config.eager_load = false
11 |
12 | # Show full error reports.
13 | config.consider_all_requests_local = true
14 |
15 | # Enable/disable caching. By default caching is disabled.
16 | if Rails.root.join('tmp/caching-dev.txt').exist?
17 | config.action_controller.perform_caching = true
18 |
19 | config.cache_store = :memory_store
20 | config.public_file_server.headers = {
21 | 'Cache-Control' => 'public, max-age=172800'
22 | }
23 | else
24 | config.action_controller.perform_caching = false
25 |
26 | config.cache_store = :null_store
27 | end
28 |
29 | # Don't care if the mailer can't send.
30 | config.action_mailer.raise_delivery_errors = false
31 |
32 | config.action_mailer.perform_caching = false
33 |
34 | # Print deprecation notices to the Rails logger.
35 | config.active_support.deprecation = :log
36 |
37 | # Raise an error on page load if there are pending migrations.
38 | config.active_record.migration_error = :page_load
39 |
40 | # Debug mode disables concatenation and preprocessing of assets.
41 | # This option may cause significant delays in view rendering with a large
42 | # number of complex assets.
43 | config.assets.debug = false
44 |
45 | # Suppress logger output for asset requests.
46 | config.assets.quiet = true
47 |
48 |
49 | config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
50 |
51 | # Raises error for missing translations
52 | # config.action_view.raise_on_missing_translations = true
53 |
54 | # Use an evented file watcher to asynchronously detect changes in source code,
55 | # routes, locales, etc. This feature depends on the listen gem.
56 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker
57 | end
58 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # Code is not reloaded between requests.
5 | config.cache_classes = true
6 |
7 | # Eager load code on boot. This eager loads most of Rails and
8 | # your application in memory, allowing both threaded web servers
9 | # and those relying on copy on write to perform better.
10 | # Rake tasks automatically ignore this option for performance.
11 | config.eager_load = true
12 |
13 | # Full error reports are disabled and caching is turned on.
14 | config.consider_all_requests_local = false
15 | config.action_controller.perform_caching = true
16 |
17 | # Disable serving static files from the `/public` folder by default since
18 | # Apache or NGINX already handles this.
19 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
20 |
21 | # Compress JavaScripts and CSS.
22 | config.assets.js_compressor = :uglifier
23 | # config.assets.css_compressor = :sass
24 |
25 | # Do not fallback to assets pipeline if a precompiled asset is missed.
26 | config.assets.compile = false
27 |
28 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
29 |
30 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
31 | # config.action_controller.asset_host = 'http://assets.example.com'
32 |
33 | # Specifies the header that your server uses for sending files.
34 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
35 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
36 |
37 | # Mount Action Cable outside main process or domain
38 | # config.action_cable.mount_path = nil
39 | # config.action_cable.url = 'wss://example.com/cable'
40 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
41 |
42 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43 | # config.force_ssl = true
44 |
45 | # Use the lowest log level to ensure availability of diagnostic information
46 | # when problems arise.
47 | config.log_level = :debug
48 |
49 | # Prepend all log lines with the following tags.
50 | config.log_tags = [ :request_id ]
51 |
52 | # Use a different cache store in production.
53 | # config.cache_store = :mem_cache_store
54 |
55 | # Use a real queuing backend for Active Job (and separate queues per environment)
56 | # config.active_job.queue_adapter = :resque
57 | # config.active_job.queue_name_prefix = "rails-airbnb-clone_#{Rails.env}"
58 | config.action_mailer.perform_caching = false
59 |
60 | # Ignore bad email addresses and do not raise email delivery errors.
61 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
62 | # config.action_mailer.raise_delivery_errors = false
63 |
64 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
65 | # the I18n.default_locale when a translation cannot be found).
66 | config.i18n.fallbacks = true
67 |
68 | # Send deprecation notices to registered listeners.
69 | config.active_support.deprecation = :notify
70 |
71 | # Use default logging formatter so that PID and timestamp are not suppressed.
72 | config.log_formatter = ::Logger::Formatter.new
73 |
74 | # Use a different logger for distributed setups.
75 | # require 'syslog/logger'
76 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
77 |
78 | if ENV["RAILS_LOG_TO_STDOUT"].present?
79 | logger = ActiveSupport::Logger.new(STDOUT)
80 | logger.formatter = config.log_formatter
81 | config.logger = ActiveSupport::TaggedLogging.new(logger)
82 | end
83 |
84 | # Do not dump schema after migrations.
85 | config.active_record.dump_schema_after_migration = false
86 | end
87 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Do not eager load code on boot. This avoids loading your whole application
11 | # just for the purpose of running a single test. If you are using a tool that
12 | # preloads Rails for running tests, you may have to set it to true.
13 | config.eager_load = false
14 |
15 | # Configure public file server for tests with Cache-Control for performance.
16 | config.public_file_server.enabled = true
17 | config.public_file_server.headers = {
18 | 'Cache-Control' => 'public, max-age=3600'
19 | }
20 |
21 | # Show full error reports and disable caching.
22 | config.consider_all_requests_local = true
23 | config.action_controller.perform_caching = false
24 |
25 | # Raise exceptions instead of rendering exception templates.
26 | config.action_dispatch.show_exceptions = false
27 |
28 | # Disable request forgery protection in test environment.
29 | config.action_controller.allow_forgery_protection = false
30 | config.action_mailer.perform_caching = false
31 |
32 | # Tell Action Mailer not to deliver emails to the real world.
33 | # The :test delivery method accumulates sent emails in the
34 | # ActionMailer::Base.deliveries array.
35 | config.action_mailer.delivery_method = :test
36 |
37 | # Print deprecation notices to the stderr.
38 | config.active_support.deprecation = :stderr
39 |
40 | # Raises error for missing translations
41 | # config.action_view.raise_on_missing_translations = true
42 | end
43 |
--------------------------------------------------------------------------------
/config/initializers/application_controller_renderer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # ApplicationController.renderer.defaults.merge!(
4 | # http_host: 'example.org',
5 | # https: false
6 | # )
7 |
--------------------------------------------------------------------------------
/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 app/assets folder are already added.
11 | # Rails.application.config.assets.precompile += %w( search.js )
12 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Specify a serializer for the signed and encrypted cookie jars.
4 | # Valid options are :json, :marshal, and :hybrid.
5 | Rails.application.config.action_dispatch.cookies_serializer = :json
6 |
--------------------------------------------------------------------------------
/config/initializers/devise.rb:
--------------------------------------------------------------------------------
1 | # Use this hook to configure devise mailer, warden hooks and so forth.
2 | # Many of these configuration options can be set straight in your model.
3 | Devise.setup do |config|
4 | # The secret key used by Devise. Devise uses this key to generate
5 | # random tokens. Changing this key will render invalid all existing
6 | # confirmation, reset password and unlock tokens in the database.
7 | # Devise will use the `secret_key_base` as its `secret_key`
8 | # by default. You can change it below and use your own secret key.
9 | # config.secret_key = 'c0ef5244beeddfc74413025e08f7945cad3d6171e58719749b242e57f7de98fcca3d5edf8cd4a271e60bed51f5397cac7d8038b01de4be1354d90e198d6a00f6'
10 |
11 | # ==> Mailer Configuration
12 | # Configure the e-mail address which will be shown in Devise::Mailer,
13 | # note that it will be overwritten if you use your own mailer class
14 | # with default "from" parameter.
15 | config.mailer_sender = 'loveteam@shareabed.com'
16 |
17 | # Configure the class responsible to send e-mails.
18 | # config.mailer = 'Devise::Mailer'
19 |
20 | # Configure the parent class responsible to send e-mails.
21 | # config.parent_mailer = 'ActionMailer::Base'
22 |
23 | # ==> ORM configuration
24 | # Load and configure the ORM. Supports :active_record (default) and
25 | # :mongoid (bson_ext recommended) by default. Other ORMs may be
26 | # available as additional gems.
27 | require 'devise/orm/active_record'
28 |
29 | # ==> Configuration for any authentication mechanism
30 | # Configure which keys are used when authenticating a user. The default is
31 | # just :email. You can configure it to use [:username, :subdomain], so for
32 | # authenticating a user, both parameters are required. Remember that those
33 | # parameters are used only when authenticating and not when retrieving from
34 | # session. If you need permissions, you should implement that in a before filter.
35 | # You can also supply a hash where the value is a boolean determining whether
36 | # or not authentication should be aborted when the value is not present.
37 | # config.authentication_keys = [:email]
38 |
39 | # Configure parameters from the request object used for authentication. Each entry
40 | # given should be a request method and it will automatically be passed to the
41 | # find_for_authentication method and considered in your model lookup. For instance,
42 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
43 | # The same considerations mentioned for authentication_keys also apply to request_keys.
44 | # config.request_keys = []
45 |
46 | # Configure which authentication keys should be case-insensitive.
47 | # These keys will be downcased upon creating or modifying a user and when used
48 | # to authenticate or find a user. Default is :email.
49 | config.case_insensitive_keys = [:email]
50 |
51 | # Configure which authentication keys should have whitespace stripped.
52 | # These keys will have whitespace before and after removed upon creating or
53 | # modifying a user and when used to authenticate or find a user. Default is :email.
54 | config.strip_whitespace_keys = [:email]
55 |
56 | # Tell if authentication through request.params is enabled. True by default.
57 | # It can be set to an array that will enable params authentication only for the
58 | # given strategies, for example, `config.params_authenticatable = [:database]` will
59 | # enable it only for database (email + password) authentication.
60 | # config.params_authenticatable = true
61 |
62 | # Tell if authentication through HTTP Auth is enabled. False by default.
63 | # It can be set to an array that will enable http authentication only for the
64 | # given strategies, for example, `config.http_authenticatable = [:database]` will
65 | # enable it only for database authentication. The supported strategies are:
66 | # :database = Support basic authentication with authentication key + password
67 | # config.http_authenticatable = false
68 |
69 | # If 401 status code should be returned for AJAX requests. True by default.
70 | # config.http_authenticatable_on_xhr = true
71 |
72 | # The realm used in Http Basic Authentication. 'Application' by default.
73 | # config.http_authentication_realm = 'Application'
74 |
75 | # It will change confirmation, password recovery and other workflows
76 | # to behave the same regardless if the e-mail provided was right or wrong.
77 | # Does not affect registerable.
78 | # config.paranoid = true
79 |
80 | # By default Devise will store the user in session. You can skip storage for
81 | # particular strategies by setting this option.
82 | # Notice that if you are skipping storage for all authentication paths, you
83 | # may want to disable generating routes to Devise's sessions controller by
84 | # passing skip: :sessions to `devise_for` in your config/routes.rb
85 | config.skip_session_storage = [:http_auth]
86 |
87 | # By default, Devise cleans up the CSRF token on authentication to
88 | # avoid CSRF token fixation attacks. This means that, when using AJAX
89 | # requests for sign in and sign up, you need to get a new CSRF token
90 | # from the server. You can disable this option at your own risk.
91 | # config.clean_up_csrf_token_on_authentication = true
92 |
93 | # When false, Devise will not attempt to reload routes on eager load.
94 | # This can reduce the time taken to boot the app but if your application
95 | # requires the Devise mappings to be loaded during boot time the application
96 | # won't boot properly.
97 | # config.reload_routes = true
98 |
99 | # ==> Configuration for :database_authenticatable
100 | # For bcrypt, this is the cost for hashing the password and defaults to 11. If
101 | # using other algorithms, it sets how many times you want the password to be hashed.
102 | #
103 | # Limiting the stretches to just one in testing will increase the performance of
104 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
105 | # a value less than 10 in other environments. Note that, for bcrypt (the default
106 | # algorithm), the cost increases exponentially with the number of stretches (e.g.
107 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
108 | config.stretches = Rails.env.test? ? 1 : 11
109 |
110 | # Set up a pepper to generate the hashed password.
111 | # config.pepper = '569f0c4bd0ffee1288b298dc4a7c5d68368a1f8597ac0947afafafa488183d1c23304c54757389a8f6949ec3d4a0da90322ed853b429a60d9963126bd7eb4cb8'
112 |
113 | # Send a notification email when the user's password is changed
114 | # config.send_password_change_notification = false
115 |
116 | # ==> Configuration for :confirmable
117 | # A period that the user is allowed to access the website even without
118 | # confirming their account. For instance, if set to 2.days, the user will be
119 | # able to access the website for two days without confirming their account,
120 | # access will be blocked just in the third day. Default is 0.days, meaning
121 | # the user cannot access the website without confirming their account.
122 | # config.allow_unconfirmed_access_for = 2.days
123 |
124 | # A period that the user is allowed to confirm their account before their
125 | # token becomes invalid. For example, if set to 3.days, the user can confirm
126 | # their account within 3 days after the mail was sent, but on the fourth day
127 | # their account can't be confirmed with the token any more.
128 | # Default is nil, meaning there is no restriction on how long a user can take
129 | # before confirming their account.
130 | # config.confirm_within = 3.days
131 |
132 | # If true, requires any email changes to be confirmed (exactly the same way as
133 | # initial account confirmation) to be applied. Requires additional unconfirmed_email
134 | # db field (see migrations). Until confirmed, new email is stored in
135 | # unconfirmed_email column, and copied to email column on successful confirmation.
136 | config.reconfirmable = true
137 |
138 | # Defines which key will be used when confirming an account
139 | # config.confirmation_keys = [:email]
140 |
141 | # ==> Configuration for :rememberable
142 | # The time the user will be remembered without asking for credentials again.
143 | # config.remember_for = 2.weeks
144 |
145 | # Invalidates all the remember me tokens when the user signs out.
146 | config.expire_all_remember_me_on_sign_out = true
147 |
148 | # If true, extends the user's remember period when remembered via cookie.
149 | # config.extend_remember_period = false
150 |
151 | # Options to be passed to the created cookie. For instance, you can set
152 | # secure: true in order to force SSL only cookies.
153 | # config.rememberable_options = {}
154 |
155 | # ==> Configuration for :validatable
156 | # Range for password length.
157 | config.password_length = 6..128
158 |
159 | # Email regex used to validate email formats. It simply asserts that
160 | # one (and only one) @ exists in the given string. This is mainly
161 | # to give user feedback and not to assert the e-mail validity.
162 | config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
163 |
164 | # ==> Configuration for :timeoutable
165 | # The time you want to timeout the user session without activity. After this
166 | # time the user will be asked for credentials again. Default is 30 minutes.
167 | # config.timeout_in = 30.minutes
168 |
169 | # ==> Configuration for :lockable
170 | # Defines which strategy will be used to lock an account.
171 | # :failed_attempts = Locks an account after a number of failed attempts to sign in.
172 | # :none = No lock strategy. You should handle locking by yourself.
173 | # config.lock_strategy = :failed_attempts
174 |
175 | # Defines which key will be used when locking and unlocking an account
176 | # config.unlock_keys = [:email]
177 |
178 | # Defines which strategy will be used to unlock an account.
179 | # :email = Sends an unlock link to the user email
180 | # :time = Re-enables login after a certain amount of time (see :unlock_in below)
181 | # :both = Enables both strategies
182 | # :none = No unlock strategy. You should handle unlocking by yourself.
183 | # config.unlock_strategy = :both
184 |
185 | # Number of authentication tries before locking an account if lock_strategy
186 | # is failed attempts.
187 | # config.maximum_attempts = 20
188 |
189 | # Time interval to unlock the account if :time is enabled as unlock_strategy.
190 | # config.unlock_in = 1.hour
191 |
192 | # Warn on the last attempt before the account is locked.
193 | # config.last_attempt_warning = true
194 |
195 | # ==> Configuration for :recoverable
196 | #
197 | # Defines which key will be used when recovering the password for an account
198 | # config.reset_password_keys = [:email]
199 |
200 | # Time interval you can reset your password with a reset password key.
201 | # Don't put a too small interval or your users won't have the time to
202 | # change their passwords.
203 | config.reset_password_within = 6.hours
204 |
205 | # When set to false, does not sign a user in automatically after their password is
206 | # reset. Defaults to true, so a user is signed in automatically after a reset.
207 | # config.sign_in_after_reset_password = true
208 |
209 | # ==> Configuration for :encryptable
210 | # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
211 | # You can use :sha1, :sha512 or algorithms from others authentication tools as
212 | # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
213 | # for default behavior) and :restful_authentication_sha1 (then you should set
214 | # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
215 | #
216 | # Require the `devise-encryptable` gem when using anything other than bcrypt
217 | # config.encryptor = :sha512
218 |
219 | # ==> Scopes configuration
220 | # Turn scoped views on. Before rendering "sessions/new", it will first check for
221 | # "users/sessions/new". It's turned off by default because it's slower if you
222 | # are using only default views.
223 | # config.scoped_views = false
224 |
225 | # Configure the default scope given to Warden. By default it's the first
226 | # devise role declared in your routes (usually :user).
227 | # config.default_scope = :user
228 |
229 | # Set this configuration to false if you want /users/sign_out to sign out
230 | # only the current scope. By default, Devise signs out all scopes.
231 | # config.sign_out_all_scopes = true
232 |
233 | # ==> Navigation configuration
234 | # Lists the formats that should be treated as navigational. Formats like
235 | # :html, should redirect to the sign in page when the user does not have
236 | # access, but formats like :xml or :json, should return 401.
237 | #
238 | # If you have any extra navigational formats, like :iphone or :mobile, you
239 | # should add them to the navigational formats lists.
240 | #
241 | # The "*/*" below is required to match Internet Explorer requests.
242 | # config.navigational_formats = ['*/*', :html]
243 |
244 | # The default HTTP method used to sign out a resource. Default is :delete.
245 | config.sign_out_via = :delete
246 |
247 | # ==> OmniAuth
248 | # Add a new OmniAuth provider. Check the wiki for more information on setting
249 | # up on your models and hooks.
250 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
251 |
252 | # ==> Warden configuration
253 | # If you want to use other strategies, that are not supported by Devise, or
254 | # change the failure app, you can configure them inside the config.warden block.
255 | #
256 | # config.warden do |manager|
257 | # manager.intercept_401 = false
258 | # manager.default_strategies(scope: :user).unshift :some_external_strategy
259 | # end
260 |
261 | # ==> Mountable engine configurations
262 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine
263 | # is mountable, there are some extra configurations to be taken into account.
264 | # The following options are available, assuming the engine is mounted as:
265 | #
266 | # mount MyEngine, at: '/my_engine'
267 | #
268 | # The router that invoked `devise_for`, in the example above, would be:
269 | # config.router_name = :my_engine
270 | #
271 | # When using OmniAuth, Devise cannot automatically set OmniAuth path,
272 | # so you need to do it manually. For the users scope, it would be:
273 | # config.omniauth_path_prefix = '/my_engine/users/auth'
274 | end
275 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/config/initializers/geocoder.rb:
--------------------------------------------------------------------------------
1 | Geocoder.configure(
2 | # Geocoding options
3 | # timeout: 3, # geocoding service timeout (secs)
4 | # lookup: :google, # name of geocoding service (symbol)
5 | # language: :en, # ISO-639 language code
6 | # use_https: false, # use HTTPS for lookup requests? (if supported)
7 | # http_proxy: nil, # HTTP proxy server (user:pass@host:port)
8 | # https_proxy: nil, # HTTPS proxy server (user:pass@host:port)
9 | # api_key: nil, # API key for geocoding service
10 | # cache: nil, # cache object (must respond to #[], #[]=, and #keys)
11 | # cache_prefix: 'geocoder:', # prefix (string) to use for all cache keys
12 |
13 | # Exceptions that should not be rescued by default
14 | # (if you want to implement custom error handling);
15 | # supports SocketError and Timeout::Error
16 | # always_raise: [],
17 |
18 | # Calculation options
19 | # units: :mi, # :km for kilometers or :mi for miles
20 | # distances: :linear # :spherical or :linear
21 |
22 |
23 | :lookup => :google,
24 | :api_key => ENV['GOOGLE_API_SERVER_KEY'],
25 | :use_https => true,
26 | :units => :km
27 | # [...]
28 | )
29 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/config/initializers/new_framework_defaults.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 | #
3 | # This file contains migration options to ease your Rails 5.0 upgrade.
4 | #
5 | # Read the Guide for Upgrading Ruby on Rails for more info on each option.
6 |
7 | # Enable per-form CSRF tokens. Previous versions had false.
8 | Rails.application.config.action_controller.per_form_csrf_tokens = true
9 |
10 | # Enable origin-checking CSRF mitigation. Previous versions had false.
11 | Rails.application.config.action_controller.forgery_protection_origin_check = true
12 |
13 | # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
14 | # Previous versions had false.
15 | ActiveSupport.to_time_preserves_timezone = true
16 |
17 | # Require `belongs_to` associations by default. Previous versions had false.
18 | Rails.application.config.active_record.belongs_to_required_by_default = true
19 |
20 | # Do not halt callback chains when a callback returns false. Previous versions had true.
21 | ActiveSupport.halt_callback_chains_on_return_false = false
22 |
23 | # Configure SSL options to enable HSTS with subdomains. Previous versions had false.
24 | Rails.application.config.ssl_options = { hsts: { subdomains: true } }
25 |
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.session_store :cookie_store, key: '_rails-airbnb-clone_session'
4 |
--------------------------------------------------------------------------------
/config/initializers/simple_form.rb:
--------------------------------------------------------------------------------
1 | # Use this setup block to configure all options available in SimpleForm.
2 | SimpleForm.setup do |config|
3 | # Wrappers are used by the form builder to generate a
4 | # complete input. You can remove any component from the
5 | # wrapper, change the order or even add your own to the
6 | # stack. The options given below are used to wrap the
7 | # whole input.
8 | config.wrappers :default, class: :input,
9 | hint_class: :field_with_hint, error_class: :field_with_errors do |b|
10 | ## Extensions enabled by default
11 | # Any of these extensions can be disabled for a
12 | # given input by passing: `f.input EXTENSION_NAME => false`.
13 | # You can make any of these extensions optional by
14 | # renaming `b.use` to `b.optional`.
15 |
16 | # Determines whether to use HTML5 (:email, :url, ...)
17 | # and required attributes
18 | b.use :html5
19 |
20 | # Calculates placeholders automatically from I18n
21 | # You can also pass a string as f.input placeholder: "Placeholder"
22 | b.use :placeholder
23 |
24 | ## Optional extensions
25 | # They are disabled unless you pass `f.input EXTENSION_NAME => true`
26 | # to the input. If so, they will retrieve the values from the model
27 | # if any exists. If you want to enable any of those
28 | # extensions by default, you can change `b.optional` to `b.use`.
29 |
30 | # Calculates maxlength from length validations for string inputs
31 | # and/or database column lengths
32 | b.optional :maxlength
33 |
34 | # Calculate minlength from length validations for string inputs
35 | b.optional :minlength
36 |
37 | # Calculates pattern from format validations for string inputs
38 | b.optional :pattern
39 |
40 | # Calculates min and max from length validations for numeric inputs
41 | b.optional :min_max
42 |
43 | # Calculates readonly automatically from readonly attributes
44 | b.optional :readonly
45 |
46 | ## Inputs
47 | b.use :label_input
48 | b.use :hint, wrap_with: { tag: :span, class: :hint }
49 | b.use :error, wrap_with: { tag: :span, class: :error }
50 |
51 | ## full_messages_for
52 | # If you want to display the full error message for the attribute, you can
53 | # use the component :full_error, like:
54 | #
55 | # b.use :full_error, wrap_with: { tag: :span, class: :error }
56 | end
57 |
58 | # The default wrapper to be used by the FormBuilder.
59 | config.default_wrapper = :default
60 |
61 | # Define the way to render check boxes / radio buttons with labels.
62 | # Defaults to :nested for bootstrap config.
63 | # inline: input + label
64 | # nested: label > input
65 | config.boolean_style = :nested
66 |
67 | # Default class for buttons
68 | config.button_class = 'btn'
69 |
70 | # Method used to tidy up errors. Specify any Rails Array method.
71 | # :first lists the first message for each field.
72 | # Use :to_sentence to list all errors for each field.
73 | # config.error_method = :first
74 |
75 | # Default tag used for error notification helper.
76 | config.error_notification_tag = :div
77 |
78 | # CSS class to add for error notification helper.
79 | config.error_notification_class = 'error_notification'
80 |
81 | # ID to add for error notification helper.
82 | # config.error_notification_id = nil
83 |
84 | # Series of attempts to detect a default label method for collection.
85 | # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
86 |
87 | # Series of attempts to detect a default value method for collection.
88 | # config.collection_value_methods = [ :id, :to_s ]
89 |
90 | # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
91 | # config.collection_wrapper_tag = nil
92 |
93 | # You can define the class to use on all collection wrappers. Defaulting to none.
94 | # config.collection_wrapper_class = nil
95 |
96 | # You can wrap each item in a collection of radio/check boxes with a tag,
97 | # defaulting to :span.
98 | # config.item_wrapper_tag = :span
99 |
100 | # You can define a class to use in all item wrappers. Defaulting to none.
101 | # config.item_wrapper_class = nil
102 |
103 | # How the label text should be generated altogether with the required text.
104 | # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
105 |
106 | # You can define the class to use on all labels. Default is nil.
107 | # config.label_class = nil
108 |
109 | # You can define the default class to be used on forms. Can be overriden
110 | # with `html: { :class }`. Defaulting to none.
111 | # config.default_form_class = nil
112 |
113 | # You can define which elements should obtain additional classes
114 | # config.generate_additional_classes_for = [:wrapper, :label, :input]
115 |
116 | # Whether attributes are required by default (or not). Default is true.
117 | # config.required_by_default = true
118 |
119 | # Tell browsers whether to use the native HTML5 validations (novalidate form option).
120 | # These validations are enabled in SimpleForm's internal config but disabled by default
121 | # in this configuration, which is recommended due to some quirks from different browsers.
122 | # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
123 | # change this configuration to true.
124 | config.browser_validations = false
125 |
126 | # Collection of methods to detect if a file type was given.
127 | # config.file_methods = [ :mounted_as, :file?, :public_filename ]
128 |
129 | # Custom mappings for input types. This should be a hash containing a regexp
130 | # to match as key, and the input type that will be used when the field name
131 | # matches the regexp as value.
132 | # config.input_mappings = { /count/ => :integer }
133 |
134 | # Custom wrappers for input types. This should be a hash containing an input
135 | # type as key and the wrapper that will be used for all inputs with specified type.
136 | # config.wrapper_mappings = { string: :prepend }
137 |
138 | # Namespaces where SimpleForm should look for custom input classes that
139 | # override default inputs.
140 | # config.custom_inputs_namespaces << "CustomInputs"
141 |
142 | # Default priority for time_zone inputs.
143 | # config.time_zone_priority = nil
144 |
145 | # Default priority for country inputs.
146 | # config.country_priority = nil
147 |
148 | # When false, do not use translations for labels.
149 | # config.translate_labels = true
150 |
151 | # Automatically discover new inputs in Rails' autoload path.
152 | # config.inputs_discovery = true
153 |
154 | # Cache SimpleForm inputs discovery
155 | # config.cache_discovery = !Rails.env.development?
156 |
157 | # Default class for inputs
158 | # config.input_class = nil
159 |
160 | # Define the default class of the input wrapper of the boolean input.
161 | config.boolean_label_class = 'checkbox'
162 |
163 | # Defines if the default input wrapper class should be included in radio
164 | # collection wrappers.
165 | # config.include_default_input_wrapper_class = true
166 |
167 | # Defines which i18n scope will be used in Simple Form.
168 | # config.i18n_scope = 'simple_form'
169 | end
170 |
--------------------------------------------------------------------------------
/config/initializers/simple_form_bootstrap.rb:
--------------------------------------------------------------------------------
1 | # Use this setup block to configure all options available in SimpleForm.
2 | SimpleForm.setup do |config|
3 | config.error_notification_class = 'alert alert-danger'
4 | config.button_class = 'btn btn-default'
5 | config.boolean_label_class = nil
6 |
7 | config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
8 | b.use :html5
9 | b.use :placeholder
10 | b.optional :maxlength
11 | b.optional :minlength
12 | b.optional :pattern
13 | b.optional :min_max
14 | b.optional :readonly
15 | b.use :label, class: 'control-label'
16 |
17 | b.use :input, class: 'form-control'
18 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
19 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
20 | end
21 |
22 | config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
23 | b.use :html5
24 | b.use :placeholder
25 | b.optional :maxlength
26 | b.optional :minlength
27 | b.optional :readonly
28 | b.use :label, class: 'control-label'
29 |
30 | b.use :input
31 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
32 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
33 | end
34 |
35 | config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
36 | b.use :html5
37 | b.optional :readonly
38 |
39 | b.wrapper tag: 'div', class: 'checkbox' do |ba|
40 | ba.use :label_input
41 | end
42 |
43 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
44 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
45 | end
46 |
47 | config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
48 | b.use :html5
49 | b.optional :readonly
50 | b.use :label, class: 'control-label'
51 | b.use :input
52 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
53 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
54 | end
55 |
56 | config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
57 | b.use :html5
58 | b.use :placeholder
59 | b.optional :maxlength
60 | b.optional :minlength
61 | b.optional :pattern
62 | b.optional :min_max
63 | b.optional :readonly
64 | b.use :label, class: 'col-sm-3 control-label'
65 |
66 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
67 | ba.use :input, class: 'form-control'
68 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
69 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
70 | end
71 | end
72 |
73 | config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
74 | b.use :html5
75 | b.use :placeholder
76 | b.optional :maxlength
77 | b.optional :minlength
78 | b.optional :readonly
79 | b.use :label, class: 'col-sm-3 control-label'
80 |
81 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
82 | ba.use :input
83 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
84 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
85 | end
86 | end
87 |
88 | config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
89 | b.use :html5
90 | b.optional :readonly
91 |
92 | b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
93 | wr.wrapper tag: 'div', class: 'checkbox' do |ba|
94 | ba.use :label_input
95 | end
96 |
97 | wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
98 | wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
99 | end
100 | end
101 |
102 | config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
103 | b.use :html5
104 | b.optional :readonly
105 |
106 | b.use :label, class: 'col-sm-3 control-label'
107 |
108 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
109 | ba.use :input
110 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
111 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
112 | end
113 | end
114 |
115 | config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
116 | b.use :html5
117 | b.use :placeholder
118 | b.optional :maxlength
119 | b.optional :minlength
120 | b.optional :pattern
121 | b.optional :min_max
122 | b.optional :readonly
123 | b.use :label, class: 'sr-only'
124 |
125 | b.use :input, class: 'form-control'
126 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
127 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
128 | end
129 |
130 | config.wrappers :multi_select, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
131 | b.use :html5
132 | b.optional :readonly
133 | b.use :label, class: 'control-label'
134 | b.wrapper tag: 'div', class: 'form-inline' do |ba|
135 | ba.use :input, class: 'form-control'
136 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
137 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
138 | end
139 | end
140 | # Wrappers for forms and inputs using the Bootstrap toolkit.
141 | # Check the Bootstrap docs (http://getbootstrap.com)
142 | # to learn about the different styles for forms and inputs,
143 | # buttons and other elements.
144 | config.default_wrapper = :vertical_form
145 | config.wrapper_mappings = {
146 | check_boxes: :vertical_radio_and_checkboxes,
147 | radio_buttons: :vertical_radio_and_checkboxes,
148 | file: :vertical_file_input,
149 | boolean: :vertical_boolean,
150 | datetime: :multi_select,
151 | date: :multi_select,
152 | time: :multi_select
153 | }
154 | end
155 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json]
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/config/locales/devise.en.yml:
--------------------------------------------------------------------------------
1 | # Additional translations at https://github.com/plataformatec/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 | password_change:
27 | subject: "Password Changed"
28 | omniauth_callbacks:
29 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
30 | success: "Successfully authenticated from %{kind} account."
31 | passwords:
32 | 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."
33 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
34 | 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."
35 | updated: "Your password has been changed successfully. You are now signed in."
36 | updated_not_active: "Your password has been changed successfully."
37 | registrations:
38 | destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
39 | signed_up: "Welcome! You have signed up successfully."
40 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
41 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
42 | 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."
43 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
44 | updated: "Your account has been updated successfully."
45 | sessions:
46 | signed_in: "Signed in successfully."
47 | signed_out: "Signed out successfully."
48 | already_signed_out: "Signed out successfully."
49 | unlocks:
50 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
51 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
52 | unlocked: "Your account has been unlocked successfully. Please sign in to continue."
53 | errors:
54 | messages:
55 | already_confirmed: "was already confirmed, please try signing in"
56 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
57 | expired: "has expired, please request a new one"
58 | not_found: "not found"
59 | not_locked: "was not locked"
60 | not_saved:
61 | one: "1 error prohibited this %{resource} from being saved:"
62 | other: "%{count} errors prohibited this %{resource} from being saved:"
63 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than 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, please read the Rails Internationalization guide
20 | # available at http://guides.rubyonrails.org/i18n.html.
21 |
22 | en:
23 | hello: "Hello world"
24 |
--------------------------------------------------------------------------------
/config/locales/simple_form.en.yml:
--------------------------------------------------------------------------------
1 | en:
2 | simple_form:
3 | "yes": 'Yes'
4 | "no": 'No'
5 | required:
6 | text: 'required'
7 | mark: '*'
8 | # You can uncomment the line below if you need to overwrite the whole required html.
9 | # When using html, text and mark won't be used.
10 | # html: '*'
11 | error_notification:
12 | default_message: "Please review the problems below:"
13 | # Examples
14 | # labels:
15 | # defaults:
16 | # password: 'Password'
17 | # user:
18 | # new:
19 | # email: 'E-mail to sign in.'
20 | # edit:
21 | # email: 'E-mail.'
22 | # hints:
23 | # defaults:
24 | # username: 'User name to sign in.'
25 | # password: 'No special characters, please.'
26 | # include_blanks:
27 | # defaults:
28 | # age: 'Rather not say'
29 | # prompts:
30 | # defaults:
31 | # age: 'Select your age'
32 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | # Puma can serve each request in a thread from an internal thread pool.
2 | # The `threads` method setting takes two numbers a minimum and maximum.
3 | # Any libraries that use thread pools should be configured to match
4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum
5 | # and maximum, this matches the default thread size of Active Record.
6 | #
7 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
8 | threads threads_count, threads_count
9 |
10 | # Specifies the `port` that Puma will listen on to receive requests, default is 3000.
11 | #
12 | port ENV.fetch("PORT") { 3000 }
13 |
14 | # Specifies the `environment` that Puma will run in.
15 | #
16 | environment ENV.fetch("RAILS_ENV") { "development" }
17 |
18 | # Specifies the number of `workers` to boot in clustered mode.
19 | # Workers are forked webserver processes. If using threads and workers together
20 | # the concurrency of the application would be max `threads` * `workers`.
21 | # Workers do not work on JRuby or Windows (both of which do not support
22 | # processes).
23 | #
24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
25 |
26 | # Use the `preload_app!` method when specifying a `workers` number.
27 | # This directive tells Puma to first boot the application and load code
28 | # before forking the application. This takes advantage of Copy On Write
29 | # process behavior so workers use less memory. If you use this option
30 | # you need to make sure to reconnect any threads in the `on_worker_boot`
31 | # block.
32 | #
33 | # preload_app!
34 |
35 | # The code in the `on_worker_boot` will be called if you are using
36 | # clustered mode by specifying a number of `workers`. After each worker
37 | # process is booted this block will be run, if you are using `preload_app!`
38 | # option you will want to use this block to reconnect to any threads
39 | # or connections that may have been created at application boot, Ruby
40 | # cannot share connections between processes.
41 | #
42 | # on_worker_boot do
43 | # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
44 | # end
45 |
46 | # Allow puma to be restarted by `rails restart` command.
47 | plugin :tmp_restart
48 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | root to: 'pages#home'
3 |
4 | mount Attachinary::Engine => "/attachinary"
5 |
6 | devise_for :users
7 | resources :beds do
8 | resources :bookings, only: [:create]
9 |
10 | end
11 | resources :bookings, only: [:index, :show, :destroy, :update] do
12 | resources :reviews, only: [:create, :index, :show]
13 | end
14 |
15 | namespace :my do
16 | resources :beds, only: [:index]
17 | resources :bookings, only: [:index, :update]
18 | end
19 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
20 | end
21 |
22 |
--------------------------------------------------------------------------------
/config/secrets.yml:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key is used for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 |
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | # You can use `rails secret` to generate a secure secret key.
9 |
10 | # Make sure the secrets in this file are kept private
11 | # if you're sharing your code publicly.
12 |
13 | development:
14 | secret_key_base: 4cd230ef2727a63439169f334794f9c48fb352a124003dee3a8ac36c1cb9c459e2fa17be64b138f0250054c2645e838e012aae7b285223584bf89bfc7ba6ea5b
15 |
16 | test:
17 | secret_key_base: 51c1199db2edcd7a3de5cf7976097b4fbd25218b0283e8cae3bd1e348a3374f69114adaa1b87c6f19d8303a474f4d0c3fcc00359454ad921dccd1027f4cc0386
18 |
19 | # Do not keep production secrets in the repository,
20 | # instead read values from the environment.
21 | production:
22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
23 |
--------------------------------------------------------------------------------
/config/spring.rb:
--------------------------------------------------------------------------------
1 | %w(
2 | .ruby-version
3 | .rbenv-vars
4 | tmp/restart.txt
5 | tmp/caching-dev.txt
6 | config/application.yml
7 | ).each { |path| Spring.watch(path) }
8 |
--------------------------------------------------------------------------------
/db/migrate/20170213145054_devise_create_users.rb:
--------------------------------------------------------------------------------
1 | class DeviseCreateUsers < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :users do |t|
4 | ## Database authenticatable
5 | t.string :email, null: false, default: ""
6 | t.string :encrypted_password, null: false, default: ""
7 |
8 | ## Recoverable
9 | t.string :reset_password_token
10 | t.datetime :reset_password_sent_at
11 |
12 | ## Rememberable
13 | t.datetime :remember_created_at
14 |
15 | ## Trackable
16 | t.integer :sign_in_count, default: 0, null: false
17 | t.datetime :current_sign_in_at
18 | t.datetime :last_sign_in_at
19 | t.inet :current_sign_in_ip
20 | t.inet :last_sign_in_ip
21 |
22 | ## Confirmable
23 | # t.string :confirmation_token
24 | # t.datetime :confirmed_at
25 | # t.datetime :confirmation_sent_at
26 | # t.string :unconfirmed_email # Only if using reconfirmable
27 |
28 | ## Lockable
29 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
30 | # t.string :unlock_token # Only if unlock strategy is :email or :both
31 | # t.datetime :locked_at
32 |
33 |
34 | t.timestamps null: false
35 | end
36 |
37 | add_index :users, :email, unique: true
38 | add_index :users, :reset_password_token, unique: true
39 | # add_index :users, :confirmation_token, unique: true
40 | # add_index :users, :unlock_token, unique: true
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/db/migrate/20170213153159_add_column_to_user.rb:
--------------------------------------------------------------------------------
1 | class AddColumnToUser < ActiveRecord::Migration[5.0]
2 | def change
3 | add_column :users, :first_name, :string
4 | add_column :users, :last_name, :string
5 | add_column :users, :gender, :string
6 | add_column :users, :gender_preferences, :string
7 | add_column :users, :description, :text
8 | add_column :users, :photo, :string
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20170213154859_create_beds.rb:
--------------------------------------------------------------------------------
1 | class CreateBeds < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :beds do |t|
4 | t.string :address
5 | t.string :title
6 | t.string :photo
7 | t.integer :price
8 | t.text :description
9 | t.references :user, foreign_key: true
10 |
11 | t.timestamps
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/db/migrate/20170213155555_create_bookings.rb:
--------------------------------------------------------------------------------
1 | class CreateBookings < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :bookings do |t|
4 | t.date :checkin_on
5 | t.date :checkout_on
6 | t.integer :value
7 | t.string :status
8 | t.references :user, foreign_key: true
9 | t.references :bed, foreign_key: true
10 |
11 | t.timestamps
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/db/migrate/20170213172408_add_column_to_bed.rb:
--------------------------------------------------------------------------------
1 | class AddColumnToBed < ActiveRecord::Migration[5.0]
2 | def change
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/db/migrate/20170213172524_add_columns_to_bed.rb:
--------------------------------------------------------------------------------
1 | class AddColumnsToBed < ActiveRecord::Migration[5.0]
2 | def change
3 | add_column :beds, :city, :string
4 | add_column :beds, :zipcode, :string
5 | add_column :beds, :country, :string
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/db/migrate/20170214102719_create_attachinary_tables.attachinary.rb:
--------------------------------------------------------------------------------
1 | # This migration comes from attachinary (originally 20120612112526)
2 | class CreateAttachinaryTables < ActiveRecord::Migration
3 | def change
4 | create_table :attachinary_files do |t|
5 | t.references :attachinariable, polymorphic: true
6 | t.string :scope
7 |
8 | t.string :public_id
9 | t.string :version
10 | t.integer :width
11 | t.integer :height
12 | t.string :format
13 | t.string :resource_type
14 | t.timestamps
15 | end
16 | add_index :attachinary_files, [:attachinariable_type, :attachinariable_id, :scope], name: 'by_scoped_parent'
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/db/migrate/20170214110259_add_pillow_to_beds.rb:
--------------------------------------------------------------------------------
1 | class AddPillowToBeds < ActiveRecord::Migration[5.0]
2 | def change
3 | add_column :beds, :pillow, :boolean
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/migrate/20170214110645_add_columns_to_beds.rb:
--------------------------------------------------------------------------------
1 | class AddColumnsToBeds < ActiveRecord::Migration[5.0]
2 | def change
3 | add_column :beds, :blanket_type, :string
4 | add_column :beds, :breakfast, :boolean
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/db/migrate/20170215102014_add_coordinates_to_beds.rb:
--------------------------------------------------------------------------------
1 | class AddCoordinatesToBeds < ActiveRecord::Migration[5.0]
2 | def change
3 | add_column :beds, :latitude, :float
4 | add_column :beds, :longitude, :float
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/db/migrate/20170216105543_create_reviews.rb:
--------------------------------------------------------------------------------
1 | class CreateReviews < ActiveRecord::Migration[5.0]
2 | def change
3 | create_table :reviews do |t|
4 | t.text :content
5 | t.integer :rating
6 | t.references :booking, foreign_key: true
7 |
8 |
9 | t.timestamps
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/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 | # Note that this schema.rb definition is the authoritative source for your
6 | # database schema. If you need to create the application database on another
7 | # system, you should be using db:schema:load, not running all the migrations
8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 | # you'll amass, the slower it'll run and the greater likelihood for issues).
10 | #
11 | # It's strongly recommended that you check this file into your version control system.
12 |
13 | ActiveRecord::Schema.define(version: 20170216105543) do
14 |
15 | # These are extensions that must be enabled in order to support this database
16 | enable_extension "plpgsql"
17 |
18 | create_table "attachinary_files", force: :cascade do |t|
19 | t.string "attachinariable_type"
20 | t.integer "attachinariable_id"
21 | t.string "scope"
22 | t.string "public_id"
23 | t.string "version"
24 | t.integer "width"
25 | t.integer "height"
26 | t.string "format"
27 | t.string "resource_type"
28 | t.datetime "created_at"
29 | t.datetime "updated_at"
30 | t.index ["attachinariable_type", "attachinariable_id", "scope"], name: "by_scoped_parent", using: :btree
31 | end
32 |
33 | create_table "beds", force: :cascade do |t|
34 | t.string "address"
35 | t.string "title"
36 | t.string "photo"
37 | t.integer "price"
38 | t.text "description"
39 | t.integer "user_id"
40 | t.datetime "created_at", null: false
41 | t.datetime "updated_at", null: false
42 | t.string "city"
43 | t.string "zipcode"
44 | t.string "country"
45 | t.boolean "pillow"
46 | t.string "blanket_type"
47 | t.boolean "breakfast"
48 | t.float "latitude"
49 | t.float "longitude"
50 | t.index ["user_id"], name: "index_beds_on_user_id", using: :btree
51 | end
52 |
53 | create_table "bookings", force: :cascade do |t|
54 | t.date "checkin_on"
55 | t.date "checkout_on"
56 | t.integer "value"
57 | t.string "status"
58 | t.integer "user_id"
59 | t.integer "bed_id"
60 | t.datetime "created_at", null: false
61 | t.datetime "updated_at", null: false
62 | t.index ["bed_id"], name: "index_bookings_on_bed_id", using: :btree
63 | t.index ["user_id"], name: "index_bookings_on_user_id", using: :btree
64 | end
65 |
66 | create_table "reviews", force: :cascade do |t|
67 | t.text "content"
68 | t.integer "rating"
69 | t.integer "booking_id"
70 | t.datetime "created_at", null: false
71 | t.datetime "updated_at", null: false
72 | t.index ["booking_id"], name: "index_reviews_on_booking_id", using: :btree
73 | end
74 |
75 | create_table "users", force: :cascade do |t|
76 | t.string "email", default: "", null: false
77 | t.string "encrypted_password", default: "", null: false
78 | t.string "reset_password_token"
79 | t.datetime "reset_password_sent_at"
80 | t.datetime "remember_created_at"
81 | t.integer "sign_in_count", default: 0, null: false
82 | t.datetime "current_sign_in_at"
83 | t.datetime "last_sign_in_at"
84 | t.inet "current_sign_in_ip"
85 | t.inet "last_sign_in_ip"
86 | t.datetime "created_at", null: false
87 | t.datetime "updated_at", null: false
88 | t.string "first_name"
89 | t.string "last_name"
90 | t.string "gender"
91 | t.string "gender_preferences"
92 | t.text "description"
93 | t.string "photo"
94 | t.index ["email"], name: "index_users_on_email", unique: true, using: :btree
95 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
96 | end
97 |
98 | add_foreign_key "beds", "users"
99 | add_foreign_key "bookings", "beds"
100 | add_foreign_key "bookings", "users"
101 | add_foreign_key "reviews", "bookings"
102 | end
103 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7 | # Character.create(name: 'Luke', movie: movies.first)
8 |
--------------------------------------------------------------------------------
/lib/assets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coralieco/rails-airbnb-clone/c4f80efa5ee839180d5f1126830c014c190e9338/lib/assets/.keep
--------------------------------------------------------------------------------
/lib/tasks/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coralieco/rails-airbnb-clone/c4f80efa5ee839180d5f1126830c014c190e9338/lib/tasks/.keep
--------------------------------------------------------------------------------
/lib/templates/erb/scaffold/_form.html.erb:
--------------------------------------------------------------------------------
1 | <%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
2 | <%%= f.error_notification %>
3 |
4 |
<%= booking.review.content %>
69 |