Skip to content

Commit

Permalink
Initial commit of sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
Jennifer Hickey committed May 8, 2012
1 parent 212afeb commit d17b485
Show file tree
Hide file tree
Showing 56 changed files with 1,189 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
log/*.log
tmp/**/*
db/*.sqlite3
vendor
public/assets
42 changes: 42 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
source 'https://rubygems.org'

gem 'rails', '3.2.2'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer'

gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

gem "tire"
gem "will_paginate", "~> 3.0"
gem 'mysql2'
125 changes: 125 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.2)
actionpack (= 3.2.2)
mail (~> 2.4.0)
actionpack (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
activerecord (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.3.1)
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
hashr (0.0.21)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
json (1.6.6)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.18)
multi_json (1.3.2)
mysql2 (0.3.11)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.2)
actionmailer (= 3.2.2)
actionpack (= 3.2.2)
activerecord (= 3.2.2)
activeresource (= 3.2.2)
activesupport (= 3.2.2)
bundler (~> 1.0)
railties (= 3.2.2)
railties (3.2.2)
actionpack (= 3.2.2)
activesupport (= 3.2.2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
rest-client (1.6.7)
mime-types (>= 1.16)
sass (3.1.16)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
thor (0.14.6)
tilt (1.3.3)
tire (0.4.0)
activemodel (>= 3.0)
hashr (~> 0.0.19)
multi_json (~> 1.0)
rake
rest-client (~> 1.6)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
uglifier (1.2.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
will_paginate (3.0.3)

PLATFORMS
ruby

DEPENDENCIES
coffee-rails (~> 3.2.1)
jquery-rails
mysql2
rails (= 3.2.2)
sass-rails (~> 3.2.3)
sqlite3
tire
uglifier (>= 1.0.3)
will_paginate (~> 3.0)
72 changes: 71 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,74 @@
rails-elastic-search
====================

Rails app that uses Tire to interact with Elastic Search deployed on Cloud Foundry
Rails app that uses [Tire](https://github.com/karmi/tire) to interact with Elastic Search deployed on Cloud Foundry. This app was originally created by running the "rails new searchapp" command explained under "ActiveModel Integration" in the Tire README.

## Setting up Elastic Search
This app connects to an instance of Elastic Search running on Cloud Foundry. Follow these instructions to deploy Elastic Search as a standalone application:

- Download and unzip the latest stable release of [Elastic Search](http://www.elasticsearch.org/download/)
- Modify config/elasticsearch.yml to use Cloud Foundry-provided host and port

```
# ElasticSearch, by default, binds itself to the 0.0.0.0 address, and listens
# on port [9200-9300] for HTTP traffic and on port [9300-9400] for node-to-node
# communication. (the range means that if the port is busy, it will automatically
# try the next port).
# Set the bind address specifically (IPv4 or IPv6):
#
network.bind_host: ${VCAP_APP_HOST}
# Set the address other nodes will use to communicate with this node. If not
# set, it is automatically derived. It must point to an actual IP address.
#
# network.publish_host: 192.168.0.1
# Set both 'bind_host' and 'publish_host':
#
network.host: ${VCAP_APP_HOST}
# Set a custom port for the node to node communication (9300 by default):
#
# transport.tcp.port: 9300
# Enable compression for all communication between nodes (disabled by default):
#
# transport.tcp.compress: true
# Set a custom port to listen for HTTP traffic:
#
http.port: ${VCAP_APP_PORT}
```

- Deploy Elastic Search to Cloud Foundry using the provided manifest. You may need to modify the manifest to generate a unique URL.

```bash
cd elasticsearch-0.19.2
cp rails-elastic-search/elastic-search-manifest.yml .
vmc push --manifest=elastic-search-manifest.yml
```

You should now be able to direct REST requests to myelasticsearch.cloudfoundry.com

## Deploying rails-elastic-search to Cloud Foundry
Cloud Foundry runs your Rails app in production mode, therefore you need to precompile assets prior to deploying:

```bash
rake assets:precompile
```

You also need to update the Tire configuration to point to the URL you've assigned to Elastic Search. Edit the following line in config/environments/production.rb:

```
Tire::Configuration.url "http://myelasticsearch.cloudfoundry.com"
```

To deploy the application to Cloud Foundry, simply use the provided manifest.yml file. You need only to provide the application with a name and URL.

```bash
vmc push
Would you like to deploy from the current directory? [Yn]:
Application Name: searchapp
Application Deployed URL [searchapp.cloudfoundry.com]:
```
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Searchapp::Application.load_tasks
Binary file added app/assets/images/rails.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
3 changes: 3 additions & 0 deletions app/assets/javascripts/articles.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
13 changes: 13 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/articles.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Articles controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
56 changes: 56 additions & 0 deletions app/assets/stylesheets/scaffolds.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
body {
background-color: #fff;
color: #333;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px; }

p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px; }

pre {
background-color: #eee;
padding: 10px;
font-size: 11px; }

a {
color: #000;
&:visited {
color: #666; }
&:hover {
color: #fff;
background-color: #000; } }

div {
&.field, &.actions {
margin-bottom: 10px; } }

#notice {
color: green; }

.field_with_errors {
padding: 2px;
background-color: red;
display: table; }

#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px;
padding-bottom: 0;
margin-bottom: 20px;
background-color: #f0f0f0;
h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
margin-bottom: 0px;
background-color: #c00;
color: #fff; }
ul li {
font-size: 12px;
list-style: square; } }
3 changes: 3 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationController < ActionController::Base
protect_from_forgery
end
Loading

0 comments on commit d17b485

Please sign in to comment.