This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails | |
import "@hotwired/turbo-rails" | |
import "controllers" | |
import * as bootstrap from "bootstrap" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# Usage: Importer.new.read | |
require 'faraday' | |
class Importer | |
AUTH_URL = "https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword" | |
FIREBASE_API_KEY="CHANGE_ME - see the Settings page of your DB" | |
FIREBASE_PROJECT_ID="CHANGE_ME - the ID / Name of your Firestore project" | |
FIREBASE_USER_EMAIL="CHANGE_ME - the email of your user" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install asdf | |
RUBY_CFLAGS="-Wno-error=implicit-function-declaration" asdf install ruby 2.6.6 | |
gem install bundler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
before_action :tenant_session | |
private | |
def tenant_session | |
if !session[:tenant] | |
redirect_to [:new, :tenant_session] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
devise_for :users | |
resources :posts | |
resources :tenant_sessions, only: [:new, :create] | |
root to: 'posts#index' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= form_for :tenant, url: tenant_sessions_path do |f| | |
.form-group | |
= f.label :name | |
= f.text_field :name, class: 'form-control' | |
.form-group | |
= f.submit 'Go', class: 'btn btn-primary' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TenantSessionsController < ApplicationController | |
skip_before_action :tenant_session | |
#layout 'devise' | |
def new | |
# clean any logged user up | |
reset_session | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'apartment/elevators/generic' | |
Apartment.configure do |config| | |
# Your Customer model | |
config.excluded_models = %w{ Customer } | |
# Customer name will be the key of the tenant | |
config.tenant_names = lambda { Customer.pluck :name } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Environment: | |
#- Macos Sierra 10.12.5 | |
#- Ruby 2.2.0 (rbenv) | |
$ brew uninstall mysql | |
$ rm -rf /usr/local/mysql # Warning: IT DELETES ALL DBs | |
$ brew install mysql56 | |
$ brew services start mysql56 | |
$ gem uninstall mysql2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str = "I'd like to buy a Belina instead of a Pampa" | |
Search.new(query: 'Belina AND Pampa').test(str) #=> true | |
Search.new(query: 'Belin*').test(str) #=> true | |
Search.new(query: '"buy a Belina"').test(str) #=> true | |
Search.new(query: 'Belina -Pampa').test(str) #=> false |
NewerOlder