Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Commit

Permalink
Basic setup and super-basic outlet model.
Browse files Browse the repository at this point in the history
Added Boxer for JSON packaging, mysql-centric database example configuration, and the core of the outlet object.
  • Loading branch information
globalspin committed Nov 9, 2011
1 parent 2f69937 commit 82c07fd
Show file tree
Hide file tree
Showing 17 changed files with 224 additions and 276 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -11,4 +11,6 @@ tmp/
*.lock
bin/
config/database.yml
.autotest
.rspec

31 changes: 16 additions & 15 deletions Gemfile
Expand Up @@ -2,11 +2,12 @@ source 'http://rubygems.org'

gem 'rails', '3.1.1'

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

gem 'sqlite3'
gem 'mysql2'

# Templates for generating JSON and other data output
# see https://github.com/gowalla/boxer
gem 'boxer'
gem 'json'

# Gems used only for assets and not required
# in production environments by default.
Expand All @@ -18,19 +19,19 @@ end

gem 'jquery-rails'

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

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

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :development do
gem 'rspec-rails', '2.6.1'
gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git'
gem 'faker', '0.3.1'
end

group :test do
# Pretty printed test output
gem 'turn', :require => false
gem 'rspec-rails', '2.6.1'
gem 'webrat', '0.7.1'
gem 'autotest', '4.4.6'
gem 'autotest-rails-pure', '4.1.2'
gem 'autotest-fsevent', '0.2.4'
gem 'autotest-growl', '0.2.9'
end
3 changes: 3 additions & 0 deletions app/assets/javascripts/outlets.js.coffee
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/outlets.css.scss
@@ -0,0 +1,3 @@
// Place all the styles related to the Outlets controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
6 changes: 6 additions & 0 deletions app/controllers/outlets_controller.rb
@@ -0,0 +1,6 @@
class OutletsController < ApplicationController
def add
@outlet = Outlet.resolve(params[:service_url])
end

end
2 changes: 2 additions & 0 deletions app/helpers/outlets_helper.rb
@@ -0,0 +1,2 @@
module OutletsHelper
end
33 changes: 33 additions & 0 deletions app/models/outlet.rb
@@ -0,0 +1,33 @@
# == Schema Information
#
# Table name: outlets
#
# id :integer(4) not null, primary key
# service_url :string(255)
# organization :string(255)
# info_url :string(255)
# account :string(255)
# language :string(255)
# updated_by :string(255)
# created_at :datetime
# updated_at :datetime
#

class Outlet < ActiveRecord::Base
attr_accessor :updated_by
attr_accessible :service_url, :organization, :info_url, :account, :language

validates :service_url,
:presence => true,
:format => { :with => URI::regexp(%w(http https)) },
:uniqueness => { :case_sensitive => false }

def self.resolve(url)
# TODO:
# Resolve the URL down to a service and account ID
# Look up existing settings for this outlet, or
# set up sensible defaults for the object.
self.new(:service_url => url)
end

end
2 changes: 2 additions & 0 deletions app/views/outlets/add.html.erb
@@ -0,0 +1,2 @@
<h1>Outlets#add</h1>
<p>Find me in app/views/outlets/add.html.erb</p>
37 changes: 15 additions & 22 deletions config/database.example.yml
@@ -1,25 +1,18 @@
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
adapter: mysql2
database: ringsail_development
encoding: utf8
collation: utf8_unicode_ci
host: localhost
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000

adapter: mysql2
database: ringsail_test
encoding: utf8
collation: utf8_unicode_ci
host: localhost
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
adapter: mysql2
database: ringsail_production
encoding: utf8
collation: utf8_unicode_ci
host: localhost
5 changes: 5 additions & 0 deletions config/initializers/boxer.rb
@@ -0,0 +1,5 @@
# Make URL helpers available in all boxes
Boxer.configure do |config|
config.box_includes = [Rails.application.routes.url_helpers]
end

5 changes: 2 additions & 3 deletions config/routes.rb
@@ -1,4 +1,6 @@
Ringsail::Application.routes.draw do
get "outlets/add"

# The priority is based upon order of creation:
# first created -> highest priority.

Expand Down Expand Up @@ -52,7 +54,4 @@

# See how all your routes lay out with "rake routes"

# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id(.:format)))'
end
16 changes: 16 additions & 0 deletions db/migrate/20111109005849_create_outlets.rb
@@ -0,0 +1,16 @@
class CreateOutlets < ActiveRecord::Migration
def change
create_table :outlets do |t|
t.string :service_url
t.string :organization
t.string :info_url
t.string :account
t.string :language
t.string :updated_by

t.timestamps
end

add_index :outlets, :account
end
end
29 changes: 29 additions & 0 deletions db/schema.rb
@@ -0,0 +1,29 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20111109005849) do

create_table "outlets", :force => true do |t|
t.string "service_url"
t.string "organization"
t.string "info_url"
t.string "account"
t.string "language"
t.string "updated_by"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "outlets", ["account"], :name => "index_outlets_on_account"

end

0 comments on commit 82c07fd

Please sign in to comment.