-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Database Model, REST-Json Controller, Sammy, Test- Template
- Loading branch information
Showing
55 changed files
with
16,453 additions
and
9,255 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class MailingListsController < ApplicationController | ||
|
||
#respond_to :json | ||
|
||
def index | ||
@lists = MailingList.full.all | ||
|
||
respond_to do |format| | ||
format.json { render :json => @lists.to_json(:include => [:host, :list_type]) } | ||
end | ||
|
||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module MailingListsHelper | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Host < ActiveRecord::Base | ||
has_many :mailing_lists | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class ListType < ActiveRecord::Base | ||
has_many :mailing_lists | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class MailingList < ActiveRecord::Base | ||
belongs_to :host | ||
belongs_to :list_type | ||
|
||
class << self | ||
|
||
def full | ||
includes [:host, :list_type] | ||
end | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
<h1>Home#index</h1> | ||
<p>Hello World from support_tool</p> | ||
<div id="main"> | ||
</div> |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# Load the rails application | ||
require File.expand_path('../application', __FILE__) | ||
|
||
# fix json issue | ||
ActiveRecord::Base.include_root_in_json = false | ||
|
||
|
||
# Initialize the rails application | ||
SupportTool::Application.initialize! |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class CreateHosts < ActiveRecord::Migration | ||
def self.up | ||
create_table :hosts do |t| | ||
t.string :name | ||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :hosts | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class CreateMailingLists < ActiveRecord::Migration | ||
def self.up | ||
create_table :mailing_lists do |t| | ||
t.integer :host_id | ||
t.integer :list_type_id | ||
t.string :name | ||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :mailing_lists | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CreateListTypes < ActiveRecord::Migration | ||
def self.up | ||
create_table :list_types do |t| | ||
t.string :name | ||
t.string :description | ||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :list_types | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 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 => 20110226213145) do | ||
|
||
create_table "hosts", :force => true do |t| | ||
t.string "name" | ||
t.datetime "created_at" | ||
t.datetime "updated_at" | ||
end | ||
|
||
create_table "list_types", :force => true do |t| | ||
t.string "name" | ||
t.string "description" | ||
t.datetime "created_at" | ||
t.datetime "updated_at" | ||
end | ||
|
||
create_table "mailing_lists", :force => true do |t| | ||
t.integer "host_id" | ||
t.integer "list_type_id" | ||
t.string "name" | ||
t.datetime "created_at" | ||
t.datetime "updated_at" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,27 @@ | ||
// Place your application-specific JavaScript functions and classes here | ||
// This file is automatically included by javascript_include_tag :defaults | ||
|
||
(function($) { | ||
|
||
var app = $.sammy('#main', function() { | ||
|
||
this.use('Template'); | ||
|
||
this.get('#/', function(context) { | ||
this.load('mailing_lists.json') | ||
.then(function(lists) { | ||
$.each(lists, function(i, list) { | ||
context.render('templates/list.template', {list: list}) | ||
.appendTo(context.$element()); | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
}); | ||
|
||
$(function() { | ||
app.run('#/'); | ||
}); | ||
|
||
})(jQuery); |
Oops, something went wrong.