This file contains hidden or 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
# Simply put it in spec/support/log_interceptor.rb | |
# | |
# Just tag a describe or context block with ':intercept_logs' | |
# | |
require 'stringio' | |
require 'logger' | |
module LogInterceptor | |
def self.logger | |
@logger ||= ActiveSupport::TaggedLogging.new(Logger.new(output)) |
This file contains hidden or 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 ApplicationHelper | |
# Hier ist der default Wert von data ein leerer Hash | |
def mein_helper(input_1, data: {}) | |
haml_tag(:picture, data: data) | |
end | |
end |
This file contains hidden or 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
# Notes for non-elixir readers | |
# | |
# In elixir, all modules and function definitions are enclosed in do … end | |
# One-line methods can be shortended to: ```def method_name(params), do: _method_body_ | |
# defp defines private methods, which can only be called from within a module | |
# | |
# |> is an operator which takes the left hand side and passes it as the first parameter to the right hand side function | |
# | |
# &transform/1 passes the function as a proc. ```transform``` is the method name. ```/1``` the number of paramaters. As we | |
# might have multiple method implementations with the same name. |
This file contains hidden or 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
# A small elastic search extension to retrieve a list of all field names in a | |
# dot notation. This way we can directly use it in ES queries. | |
# | |
# Example: | |
# | |
# # in app/models/transaction.rb | |
# class Transaction < ActiveRecord::Base | |
# include ElasticSearch::FieldNames | |
# end | |
# |
This file contains hidden or 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
# spec/support/database_cleaner.rb | |
# | |
# Set sane default for database cleaner and add a meta tag to enable database commits. | |
# This is important if you need to test after_commit callbacks in rails. (i.e. elasticsearch) | |
# | |
require 'database_cleaner' | |
RSpec.configure do |config| | |
config.before(:suite) do | |
DatabaseCleaner.strategy = :transaction |
This file contains hidden or 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
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = '2' | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
# Base image optimized for vagrant and docker | |
config.vm.box = 'phusion/ubuntu-14.04-amd64' | |
# Create a forwarded port mapping which allows access to a specific port | |
# within the machine from a port on the host machine. | |
config.vm.network 'forwarded_port', guest: 4243, host: 4243 # docker |
This file contains hidden or 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
defmodule Chat.Client do | |
def join(server) do | |
client_send server, :join | |
end | |
def say(server, message) do | |
client_send server, { :say, message } | |
end | |
def leave(server) do |
This file contains hidden or 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
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = '2' | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
# Base image optimized for vagrant and docker | |
config.vm.box = 'phusion/ubuntu-14.04-amd64' | |
# Create a forwarded port mapping which allows access to a specific port | |
# within the machine from a port on the host machine. | |
config.vm.network 'forwarded_port', guest: 4243, host: 4243 # docker |
This file contains hidden or 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
# Start your elastic search with elasticsearch --config=path/to/your/config | |
##################### Elasticsearch Configuration Example ##################### | |
# This file contains an overview of various configuration settings, | |
# targeted at operations staff. Application developers should | |
# consult the guide at <http://elasticsearch.org/guide>. | |
# | |
# The installation procedure is covered at | |
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/setup.html>. |
This file contains hidden or 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 new searchapp --skip --skip-bundle --template https://raw.github.com/elasticsearch/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/03-complex.rb | |
# (See: 01-basic.rb, 02-pretty.rb) | |
append_to_file 'README.rdoc', <<-README | |
== [3] Expert | |
The `expert` template changes to a complex database schema with model relationships: article belongs | |
to a category, has many authors and comments. |