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
apt update && apt upgrade | |
apt install ruby vim git nodejs | |
apt install ruby-dev libxml2-dev libxslt-dev pkg-config make clang | |
gem install nokogiri -- --use-system-libraries | |
apt install libsqlite-dev | |
gem install sqlite3 |
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
module Searcheable | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def pluck(*fields) | |
ElasticRelation.new(self).pluck(*fields) | |
end | |
def find_by(terms) |
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 Visit | |
include Mongoid::Document | |
field :counter, type: Integer | |
def increment! | |
self.inc(counter: 1) | |
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
class Visit | |
include Mongoid::Document | |
field :counter, type: Integer | |
def increment! | |
self.counter += 1 | |
self.save! | |
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
class DashboardController < ApplicationController | |
include IncrementableVisits | |
def index | |
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
module IncrementableVisits | |
extend ActiveSupport::Concern | |
included do | |
before_action :increment_visits, only: [:index, :show, :new, :edit] | |
end | |
def increment_visits | |
current_user.inc(visits: 1) # Mongoid ODM example | |
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
class ApplicationController < ActionController::Base | |
before_action :increment_visits, only: [:index, :show, :new, :edit] | |
private | |
def increment_visits | |
current_user.inc(visits: 1) # Mongoid ODM example | |
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
production: | |
sessions: | |
default: | |
database: db_development | |
username: my_username | |
password: my_password | |
hosts: | |
- myserverip:27017 | |
secondary: | |
database: db2_development |
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 Url | |
include Mongoid::Document | |
store_in database: 'db2_development', client: 'secondary' | |
shard_key :id | |
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
class Url | |
include Mongoid::Document | |
store_in database: 'db2_development', client: 'secondary' | |
end |