Skip to content
Browse files

first commit

  • Loading branch information...
0 parents commit 4d43ac24daaee9c61067b618fda96442897bd220 @bbenezech committed Sep 26, 2011
Showing with 1,363 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +17 −0 Gemfile
  3. +151 −0 Gemfile.lock
  4. +256 −0 README
  5. +7 −0 Rakefile
  6. +3 −0 app/controllers/application_controller.rb
  7. +2 −0 app/helpers/application_helper.rb
  8. +8 −0 app/locales/models.en.yml
  9. +8 −0 app/models/ball.rb
  10. +5 −0 app/models/cms.rb
  11. +5 −0 app/models/cms/basic_page.rb
  12. +3 −0 app/models/comment.rb
  13. +8 −0 app/models/division.rb
  14. +11 −0 app/models/draft.rb
  15. +5 −0 app/models/fan.rb
  16. +6 −0 app/models/field_test.rb
  17. +10 −0 app/models/league.rb
  18. +15 −0 app/models/player.rb
  19. +6 −0 app/models/rel_test.rb
  20. +22 −0 app/models/team.rb
  21. +18 −0 app/models/user.rb
  22. +13 −0 app/views/layouts/application.html.erb
  23. +4 −0 config.ru
  24. +45 −0 config/application.rb
  25. +6 −0 config/boot.rb
  26. +22 −0 config/database.yml
  27. +5 −0 config/environment.rb
  28. +27 −0 config/environments/development.rb
  29. +51 −0 config/environments/production.rb
  30. +39 −0 config/environments/test.rb
  31. +7 −0 config/initializers/backtrace_silencers.rb
  32. +142 −0 config/initializers/devise.rb
  33. +10 −0 config/initializers/inflections.rb
  34. +5 −0 config/initializers/mime_types.rb
  35. +3 −0 config/initializers/rails_admin.rb
  36. +7 −0 config/initializers/secret_token.rb
  37. +8 −0 config/initializers/session_store.rb
  38. +1 −0 config/locales
  39. +8 −0 config/routes.rb
  40. +13 −0 db/migrate/00000000000001_create_divisions_migration.rb
  41. +19 −0 db/migrate/00000000000002_create_drafts_migration.rb
  42. +12 −0 db/migrate/00000000000003_create_leagues_migration.rb
  43. +20 −0 db/migrate/00000000000004_create_players_migration.rb
  44. +22 −0 db/migrate/00000000000005_create_teams_migration.rb
  45. +19 −0 db/migrate/00000000000006_devise_create_users.rb
  46. +18 −0 db/migrate/00000000000007_create_histories_table.rb
  47. +12 −0 db/migrate/00000000000008_create_fans_migration.rb
  48. +11 −0 db/migrate/00000000000009_create_fans_teams_migration.rb
  49. +9 −0 db/migrate/00000000000010_add_revenue_to_team_migration.rb
  50. +9 −0 db/migrate/00000000000011_add_suspended_to_player_migration.rb
  51. +16 −0 db/migrate/00000000000012_add_avatar_columns_to_user.rb
  52. +9 −0 db/migrate/00000000000013_add_roles_to_user.rb
  53. +9 −0 db/migrate/00000000000014_add_color_to_team_migration.rb
  54. +15 −0 db/migrate/20101223222233_create_rel_tests.rb
  55. +15 −0 db/migrate/20110103205808_create_comments.rb
  56. +9 −0 db/migrate/20110123042530_rename_histories_to_rails_admin_histories.rb
  57. +22 −0 db/migrate/20110224184303_create_field_tests.rb
  58. +14 −0 db/migrate/20110328193014_create_cms_basic_pages.rb
  59. +9 −0 db/migrate/20110329183136_remove_league_id_from_teams.rb
  60. +9 −0 db/migrate/20110607152842_add_format_to_field_test.rb
  61. +12 −0 db/migrate/20110714095433_create_balls.rb
  62. +6 −0 db/migrate/20110831090841_add_protected_field_and_restricted_field_to_field_tests.rb
  63. +19 −0 db/migrate/20110901131551_change_division_primary_key.rb
  64. +5 −0 db/migrate/20110901142530_rename_league_id_foreign_key_on_divisions.rb
  65. +21 −0 db/migrate/20110901150912_set_primary_key_not_null_for_divisions.rb
  66. +9 −0 db/migrate/20110901154834_change_length_for_rails_admin_histories.rb
  67. +18 −0 db/seeds.rb
  68. +2 −0 doc/README_FOR_APP
  69. 0 lib/tasks/.gitkeep
  70. +1 −0 public
  71. +6 −0 script/rails
  72. 0 vendor/plugins/.gitkeep
4 .gitignore
@@ -0,0 +1,4 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/
17 Gemfile
@@ -0,0 +1,17 @@
+source 'http://rubygems.org'
+
+gem 'rails', '~>3.1.0'
+gem 'json'
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails', '~> 3.1.0.rc'
+ gem 'coffee-rails', '~> 3.1.0.rc'
+ gem 'uglifier'
+end
+
+gem 'rails_admin', :git => 'git://github.com/bbenezech/rails_admin.git', :branch => 'bootstrap'
+gem 'devise', '~> 1.4'
+gem 'mlb', '~> 0.5.5'
+gem 'paperclip', '~> 2.3.16'
151 Gemfile.lock
@@ -0,0 +1,151 @@
+GIT
+ remote: git://github.com/bbenezech/rails_admin.git
+ revision: 2875cded280a06de09d4cd65b561f8e07f6ce4ea
+ branch: bootstrap
+ specs:
+ rails_admin (0.0.1)
+ builder (~> 3.0.0)
+ haml (>= 3.1.0, < 3.3.0)
+ rails (~> 3.1.0)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.0)
+ actionpack (= 3.1.0)
+ mail (~> 2.3.0)
+ actionpack (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.2)
+ rack-cache (~> 1.0.3)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.0)
+ activemodel (3.1.0)
+ activesupport (= 3.1.0)
+ bcrypt-ruby (~> 3.0.0)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ activesupport (3.1.0)
+ multi_json (~> 1.0)
+ addressable (2.2.6)
+ arel (2.2.1)
+ bcrypt-ruby (3.0.1)
+ builder (3.0.0)
+ cocaine (0.2.0)
+ coffee-rails (3.1.1)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.1.0)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.1.2)
+ devise (1.4.7)
+ bcrypt-ruby (~> 3.0)
+ orm_adapter (~> 0.0.3)
+ warden (~> 1.0.3)
+ erubis (2.7.0)
+ execjs (1.2.9)
+ multi_json (~> 1.0)
+ faraday (0.7.4)
+ addressable (~> 2.2.6)
+ multipart-post (~> 1.1.0)
+ rack (>= 1.1.0, < 2)
+ faraday_middleware (0.7.0)
+ faraday (~> 0.7.3)
+ haml (3.1.3)
+ hike (1.2.1)
+ i18n (0.6.0)
+ json (1.6.1)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ mlb (0.5.5)
+ faraday (~> 0.7.4)
+ faraday_middleware (~> 0.7.0)
+ multi_json (~> 1.0.0)
+ multi_json (1.0.3)
+ multipart-post (1.1.3)
+ orm_adapter (0.0.5)
+ paperclip (2.3.16)
+ activerecord (>= 2.3.0)
+ activesupport (>= 2.3.2)
+ cocaine (>= 0.0.2)
+ mime-types
+ polyglot (0.3.2)
+ rack (1.3.3)
+ rack-cache (1.0.3)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.1.0)
+ actionmailer (= 3.1.0)
+ actionpack (= 3.1.0)
+ activerecord (= 3.1.0)
+ activeresource (= 3.1.0)
+ activesupport (= 3.1.0)
+ bundler (~> 1.0)
+ railties (= 3.1.0)
+ railties (3.1.0)
+ actionpack (= 3.1.0)
+ activesupport (= 3.1.0)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2)
+ rdoc (3.9.4)
+ sass (3.1.7)
+ sass-rails (3.1.2)
+ actionpack (~> 3.1.0)
+ railties (~> 3.1.0)
+ sass (>= 3.1.4)
+ sprockets (~> 2.0.0)
+ tilt (~> 1.3.2)
+ sprockets (2.0.0)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.29)
+ uglifier (1.0.3)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+ warden (1.0.5)
+ rack (>= 1.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-rails (~> 3.1.0.rc)
+ devise (~> 1.4)
+ json
+ mlb (~> 0.5.5)
+ paperclip (~> 2.3.16)
+ rails (~> 3.1.0)
+ rails_admin!
+ sass-rails (~> 3.1.0.rc)
+ uglifier
256 README
@@ -0,0 +1,256 @@
+== Welcome to Rails
+
+Rails is a web-application framework that includes everything needed to create
+database-backed web applications according to the Model-View-Control pattern.
+
+This pattern splits the view (also called the presentation) into "dumb"
+templates that are primarily responsible for inserting pre-built data in between
+HTML tags. The model contains the "smart" domain objects (such as Account,
+Product, Person, Post) that holds all the business logic and knows how to
+persist themselves to a database. The controller handles the incoming requests
+(such as Save New Account, Update Product, Show Post) by manipulating the model
+and directing data to the view.
+
+In Rails, the model is handled by what's called an object-relational mapping
+layer entitled Active Record. This layer allows you to present the data from
+database rows as objects and embellish these data objects with business logic
+methods. You can read more about Active Record in
+link:files/vendor/rails/activerecord/README.html.
+
+The controller and view are handled by the Action Pack, which handles both
+layers by its two parts: Action View and Action Controller. These two layers
+are bundled in a single package due to their heavy interdependence. This is
+unlike the relationship between the Active Record and Action Pack that is much
+more separate. Each of these packages can be used independently outside of
+Rails. You can read more about Action Pack in
+link:files/vendor/rails/actionpack/README.html.
+
+
+== Getting Started
+
+1. At the command prompt, create a new Rails application:
+ <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
+
+2. Change directory to <tt>myapp</tt> and start the web server:
+ <tt>cd myapp; rails server</tt> (run with --help for options)
+
+3. Go to http://localhost:3000/ and you'll see:
+ "Welcome aboard: You're riding Ruby on Rails!"
+
+4. Follow the guidelines to start developing your application. You can find
+the following resources handy:
+
+* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
+* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
+
+
+== Debugging Rails
+
+Sometimes your application goes wrong. Fortunately there are a lot of tools that
+will help you debug it and get it back on the rails.
+
+First area to check is the application log files. Have "tail -f" commands
+running on the server.log and development.log. Rails will automatically display
+debugging and runtime information to these files. Debugging info will also be
+shown in the browser on requests from 127.0.0.1.
+
+You can also log your own messages directly into the log file from your code
+using the Ruby logger class from inside your controllers. Example:
+
+ class WeblogController < ActionController::Base
+ def destroy
+ @weblog = Weblog.find(params[:id])
+ @weblog.destroy
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
+ end
+ end
+
+The result will be a message in your log file along the lines of:
+
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
+
+More information on how to use the logger is at http://www.ruby-doc.org/core/
+
+Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
+several books available online as well:
+
+* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
+* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
+
+These two books will bring you up to speed on the Ruby language and also on
+programming in general.
+
+
+== Debugger
+
+Debugger support is available through the debugger command when you start your
+Mongrel or WEBrick server with --debugger. This means that you can break out of
+execution at any point in the code, investigate and change the model, and then,
+resume execution! You need to install ruby-debug to run the server in debugging
+mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
+
+ class WeblogController < ActionController::Base
+ def index
+ @posts = Post.find(:all)
+ debugger
+ end
+ end
+
+So the controller will accept the action, run the first line, then present you
+with a IRB prompt in the server window. Here you can do things like:
+
+ >> @posts.inspect
+ => "[#<Post:0x14a6be8
+ @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
+ #<Post:0x14a6620
+ @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
+ >> @posts.first.title = "hello from a debugger"
+ => "hello from a debugger"
+
+...and even better, you can examine how your runtime objects actually work:
+
+ >> f = @posts.first
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
+ >> f.
+ Display all 152 possibilities? (y or n)
+
+Finally, when you're ready to resume execution, you can enter "cont".
+
+
+== Console
+
+The console is a Ruby shell, which allows you to interact with your
+application's domain model. Here you'll have all parts of the application
+configured, just like it is when the application is running. You can inspect
+domain models, change values, and save to the database. Starting the script
+without arguments will launch it in the development environment.
+
+To start the console, run <tt>rails console</tt> from the application
+directory.
+
+Options:
+
+* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
+ made to the database.
+* Passing an environment name as an argument will load the corresponding
+ environment. Example: <tt>rails console production</tt>.
+
+To reload your controllers and models after launching the console run
+<tt>reload!</tt>
+
+More information about irb can be found at:
+link:http://www.rubycentral.com/pickaxe/irb.html
+
+
+== dbconsole
+
+You can go to the command line of your database directly through <tt>rails
+dbconsole</tt>. You would be connected to the database with the credentials
+defined in database.yml. Starting the script without arguments will connect you
+to the development database. Passing an argument will connect you to a different
+database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
+PostgreSQL and SQLite 3.
+
+== Description of Contents
+
+The default directory structure of a generated Ruby on Rails application:
+
+ |-- app
+ | |-- controllers
+ | |-- helpers
+ | |-- mailers
+ | |-- models
+ | `-- views
+ | `-- layouts
+ |-- config
+ | |-- environments
+ | |-- initializers
+ | `-- locales
+ |-- db
+ |-- doc
+ |-- lib
+ | `-- tasks
+ |-- log
+ |-- public
+ | |-- images
+ | |-- javascripts
+ | `-- stylesheets
+ |-- script
+ |-- test
+ | |-- fixtures
+ | |-- functional
+ | |-- integration
+ | |-- performance
+ | `-- unit
+ |-- tmp
+ | |-- cache
+ | |-- pids
+ | |-- sessions
+ | `-- sockets
+ `-- vendor
+ `-- plugins
+
+app
+ Holds all the code that's specific to this particular application.
+
+app/controllers
+ Holds controllers that should be named like weblogs_controller.rb for
+ automated URL mapping. All controllers should descend from
+ ApplicationController which itself descends from ActionController::Base.
+
+app/models
+ Holds models that should be named like post.rb. Models descend from
+ ActiveRecord::Base by default.
+
+app/views
+ Holds the template files for the view that should be named like
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
+ eRuby syntax by default.
+
+app/views/layouts
+ Holds the template files for layouts to be used with views. This models the
+ common header/footer method of wrapping views. In your views, define a layout
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
+ Inside default.html.erb, call <% yield %> to render the view using this
+ layout.
+
+app/helpers
+ Holds view helpers that should be named like weblogs_helper.rb. These are
+ generated for you automatically when using generators for controllers.
+ Helpers can be used to wrap functionality for your views into methods.
+
+config
+ Configuration files for the Rails environment, the routing map, the database,
+ and other dependencies.
+
+db
+ Contains the database schema in schema.rb. db/migrate contains all the
+ sequence of Migrations for your schema.
+
+doc
+ This directory is where your application documentation will be stored when
+ generated using <tt>rake doc:app</tt>
+
+lib
+ Application specific libraries. Basically, any kind of custom code that
+ doesn't belong under controllers, models, or helpers. This directory is in
+ the load path.
+
+public
+ The directory available for the web server. Contains subdirectories for
+ images, stylesheets, and javascripts. Also contains the dispatchers and the
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
+ server.
+
+script
+ Helper scripts for automation and generation.
+
+test
+ Unit and functional tests along with fixtures. When using the rails generate
+ command, template test files will be generated for you and placed in this
+ directory.
+
+vendor
+ External libraries that the application depends on. Also includes the plugins
+ subdirectory. If the app has frozen rails, those gems also go here, under
+ vendor/rails/. This directory is in the load path.
7 Rakefile
@@ -0,0 +1,7 @@
+# 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__)
+require 'rake'
+
+DummyApp::Application.load_tasks
3 app/controllers/application_controller.rb
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
2 app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
8 app/locales/models.en.yml
@@ -0,0 +1,8 @@
+en:
+ activerecord:
+ attributes:
+ fan:
+ name: His Name
+ team:
+ manager: Team Manager
+ fans: Some Fans
8 app/models/ball.rb
@@ -0,0 +1,8 @@
+class Ball < ActiveRecord::Base
+
+ validates_presence_of :color
+
+ def to_param
+ color.present? ? color.downcase.gsub(" ", "-") : id
+ end
+end
5 app/models/cms.rb
@@ -0,0 +1,5 @@
+module Cms
+ def self.table_name_prefix
+ 'cms_'
+ end
+end
5 app/models/cms/basic_page.rb
@@ -0,0 +1,5 @@
+module Cms
+ class BasicPage < ActiveRecord::Base
+ validates :title, :content, :presence => true
+ end
+end
3 app/models/comment.rb
@@ -0,0 +1,3 @@
+class Comment < ActiveRecord::Base
+ belongs_to :commentable, :polymorphic => true
+end
8 app/models/division.rb
@@ -0,0 +1,8 @@
+class Division < ActiveRecord::Base
+ set_primary_key :custom_id
+ validates_numericality_of(:custom_league_id, :only_integer => true)
+ validates_presence_of(:name)
+
+ belongs_to :league, :foreign_key => 'custom_league_id'
+ has_many :teams
+end
11 app/models/draft.rb
@@ -0,0 +1,11 @@
+class Draft < ActiveRecord::Base
+ validates_numericality_of(:player_id, :only_integer => true)
+ validates_numericality_of(:team_id, :only_integer => true)
+ validates_presence_of(:date)
+ validates_numericality_of(:round, :only_integer => true)
+ validates_numericality_of(:pick, :only_integer => true)
+ validates_numericality_of(:overall, :only_integer => true)
+
+ belongs_to(:team)
+ belongs_to(:player)
+end
5 app/models/fan.rb
@@ -0,0 +1,5 @@
+class Fan < ActiveRecord::Base
+ validates_presence_of(:name)
+ belongs_to :fanable, :polymorphic => true
+ has_and_belongs_to_many :teams
+end
6 app/models/field_test.rb
@@ -0,0 +1,6 @@
+class FieldTest < ActiveRecord::Base
+ has_one :comment, :as => :commentable
+ attr_accessible :comment_id, :string_field, :text_field, :integer_field, :float_field, :decimal_field, :datetime_field, :timestamp_field, :time_field, :date_field, :boolean_field, :created_at, :updated_at, :format
+ attr_accessible :comment_id, :string_field, :text_field, :integer_field, :float_field, :decimal_field, :datetime_field, :timestamp_field, :time_field, :date_field, :boolean_field, :created_at, :updated_at, :format, :restricted_field, :as => :custom_role
+ attr_accessible :comment_id, :string_field, :text_field, :integer_field, :float_field, :decimal_field, :datetime_field, :timestamp_field, :time_field, :date_field, :boolean_field, :created_at, :updated_at, :format, :protected_field, :as => :extra_safe_role
+end
10 app/models/league.rb
@@ -0,0 +1,10 @@
+class League < ActiveRecord::Base
+ validates_presence_of(:name)
+
+ has_many :divisions, :foreign_key => 'custom_league_id'
+ has_many :teams, :through => :divisions, :readonly => true
+
+ def custom_name
+ "League '#{self.name}'"
+ end
+end
15 app/models/player.rb
@@ -0,0 +1,15 @@
+class Player < ActiveRecord::Base
+ validates_presence_of(:name)
+ validates_numericality_of(:number, :only_integer => true)
+ validates_uniqueness_of(:number, :scope => :team_id, :message => "There is already a player with that number on this team")
+
+ validates_each :name do |record, attr, value|
+ record.errors.add(:base, "Player is cheating") if value.to_s =~ /on steroids/
+ end
+
+ belongs_to :team, :inverse_of => :players
+ has_one :draft, :dependent => :destroy
+ has_many :comments, :as => :commentable
+
+ attr_protected :suspended
+end
6 app/models/rel_test.rb
@@ -0,0 +1,6 @@
+class RelTest < ActiveRecord::Base
+ validates_numericality_of(:player_id, :only_integer => true)
+ belongs_to :league
+ belongs_to :division
+ belongs_to :player
+end
22 app/models/team.rb
@@ -0,0 +1,22 @@
+class Team < ActiveRecord::Base
+ validates_numericality_of :division_id, :only_integer => true
+ validates_presence_of :manager
+ validates_numericality_of :founded, :only_integer => true
+ validates_numericality_of :wins, :only_integer => true
+ validates_numericality_of :losses, :only_integer => true
+ validates_numericality_of :win_percentage
+ validates_numericality_of :revenue, :allow_nil => true
+
+ belongs_to :division
+ has_many :players, :inverse_of => :team
+ has_and_belongs_to_many :fans
+ has_many :comments, :as => :commentable
+
+ def player_names_truncated
+ players.map{|p| p.name}.join(", ")[0..32]
+ end
+
+ def color_enum
+ ['white', 'black', 'red', 'green', 'blue']
+ end
+end
18 app/models/user.rb
@@ -0,0 +1,18 @@
+class User < ActiveRecord::Base
+ # Include default devise modules. Others available are:
+ # :token_authenticatable, :confirmable, :lockable and :timeoutable
+ devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
+
+ serialize :roles, Array
+
+ # Setup accessible (or protected) attributes for your model
+ #attr_accessible :email, :password, :password_confirmation, :remember_me, :roles, :avatar
+
+
+ # Add Paperclip support for avatars
+ has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
+
+ def attr_accessible_role
+ :custom_role
+ end
+end
13 app/views/layouts/application.html.erb
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>DummyApp</title>
+ <%= stylesheet_link_tag :all %>
+ <%= csrf_meta_tag %>
+</head>
+<body>
+
+<%= yield %>
+
+</body>
+</html>
4 config.ru
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run DummyApp::Application
45 config/application.rb
@@ -0,0 +1,45 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+require 'devise'
+require 'paperclip'
+
+# If you have a Gemfile, require the default gems, the ones in the
+# current environment and also include :assets gems if in development
+# or test environments.
+Bundler.require *Rails.groups(:assets) if defined?(Bundler)
+
+module DummyApp
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ # config.autoload_paths += %W(#{config.root}/extras)
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ config.i18n.load_path += Dir[Rails.root.join('app', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # Configure the default encoding used in templates for Ruby 1.9.
+ config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters += [:password]
+
+ # Enable the asset pipeline
+ config.assets.enabled = true
+ end
+end
6 config/boot.rb
@@ -0,0 +1,6 @@
+require 'rubygems'
+
+# Set up gems listed in the Gemfile.
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+
+require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
22 config/database.yml
@@ -0,0 +1,22 @@
+# SQLite version 3.x
+# gem install 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.
+test:
+ adapter: sqlite3
+ database: ':memory:'
+ pool: 5
+ timeout: 5000
+
+production:
+ adapter: sqlite3
+ database: db/production.sqlite3
+ pool: 5
+ timeout: 5000
5 config/environment.rb
@@ -0,0 +1,5 @@
+# Load the rails application
+require File.expand_path('../application', __FILE__)
+
+# Initialize the rails application
+DummyApp::Application.initialize!
27 config/environments/development.rb
@@ -0,0 +1,27 @@
+DummyApp::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.cache_classes = false
+
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Don't care if the mailer can't send
+ config.action_mailer.raise_delivery_errors = false
+
+ # Print deprecation notices to the Rails logger
+ config.active_support.deprecation = :log
+
+ # Only use best-standards-support built into browsers
+ config.action_dispatch.best_standards_support = :builtin
+
+ # Do not compress assets
+ config.assets.compress = false
+end
51 config/environments/production.rb
@@ -0,0 +1,51 @@
+DummyApp::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # Code is not reloaded between requests
+ config.cache_classes = true
+
+ # Full error reports are disabled and caching is turned on
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Disable Rails's static asset server (Apache or nginx will already do this)
+ config.serve_static_assets = false
+
+ # Compress JavaScripts and CSS
+ config.assets.compress = true
+
+ # Specifies the header that your server uses for sending files
+ # (comment out if your front-end server doesn't support this)
+ config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # See everything in the log (default is :info)
+ # config.log_level = :debug
+
+ # Use a different logger for distributed setups
+ # config.logger = SyslogLogger.new
+
+ # Use a different cache store in production
+ # config.cache_store = :mem_cache_store
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
+ # config.action_controller.asset_host = "http://assets.example.com"
+
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
+ # config.assets.precompile += %w( search.js )
+
+ # Disable delivery errors, bad email addresses will be ignored
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable threaded mode
+ # config.threadsafe!
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation can not be found)
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners
+ config.active_support.deprecation = :notify
+end
39 config/environments/test.rb
@@ -0,0 +1,39 @@
+DummyApp::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Configure static asset server for tests with Cache-Control for performance
+ config.serve_static_assets = true
+ config.static_cache_control = "public, max-age=3600"
+
+ # Log error messages when you accidentally call methods on nil
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = true
+
+ # Disable request forgery protection in test environment
+ config.action_controller.allow_forgery_protection = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+end
7 config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
142 config/initializers/devise.rb
@@ -0,0 +1,142 @@
+# Use this hook to configure devise mailer, warden hooks and so forth. The first
+# four configuration values can also be set straight in your models.
+Devise.setup do |config|
+ # ==> Mailer Configuration
+ # Configure the e-mail address which will be shown in DeviseMailer.
+ config.mailer_sender = "please-change-me@config-initializers-devise.com"
+
+ # Configure the class responsible to send e-mails.
+ # config.mailer = "Devise::Mailer"
+
+ # ==> ORM configuration
+ # Load and configure the ORM. Supports :active_record (default) and
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
+ # available as additional gems.
+ require 'devise/orm/active_record'
+
+ # ==> Configuration for any authentication mechanism
+ # Configure which keys are used when authenticating an user. By default is
+ # just :email. You can configure it to use [:username, :subdomain], so for
+ # authenticating an user, both parameters are required. Remember that those
+ # parameters are used only when authenticating and not when retrieving from
+ # session. If you need permissions, you should implement that in a before filter.
+ # config.authentication_keys = [ :email ]
+
+ # Tell if authentication through request.params is enabled. True by default.
+ # config.params_authenticatable = true
+
+ # Tell if authentication through HTTP Basic Auth is enabled. True by default.
+ # config.http_authenticatable = true
+
+ # Set this to true to use Basic Auth for AJAX requests. True by default.
+ # config.http_authenticatable_on_xhr = true
+
+ # The realm used in Http Basic Authentication
+ # config.http_authentication_realm = "Application"
+
+ # ==> Configuration for :database_authenticatable
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
+ # using other encryptors, it sets how many times you want the password re-encrypted.
+ config.stretches = 10
+
+ # Define which will be the encryption algorithm. Devise also supports encryptors
+ # from others authentication tools as :clearance_sha1, :authlogic_sha512 (then
+ # you should set stretches above to 20 for default behavior) and :restful_authentication_sha1
+ # (then you should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
+ # config.encryptor = :bcrypt
+
+ # Setup a pepper to generate the encrypted password.
+ config.pepper = "217a7c1b4c6260f98b5ace0a47813057020cb3c0becddd46da9497d981b906111725015948c356dc1315e3e85548c0a9ad8ea849c0385c972a6a09d071219ac6"
+
+ # ==> Configuration for :confirmable
+ # The time you want to give your user to confirm his account. During this time
+ # he will be able to access your application without confirming. Default is nil.
+ # When confirm_within is zero, the user won't be able to sign in without confirming.
+ # You can use this to let your user access some features of your application
+ # without confirming the account, but blocking it after a certain period
+ # (ie 2 days).
+ # config.confirm_within = 2.days
+
+ # ==> Configuration for :rememberable
+ # The time the user will be remembered without asking for credentials again.
+ # config.remember_for = 2.weeks
+
+ # If true, a valid remember token can be re-used between multiple browsers.
+ # config.remember_across_browsers = true
+
+ # If true, extends the user's remember period when remembered via cookie.
+ # config.extend_remember_period = false
+
+ # ==> Configuration for :validatable
+ # Range for password length
+ # config.password_length = 6..20
+
+ # Regex to use to validate the email address
+ # config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
+
+ # ==> Configuration for :timeoutable
+ # The time you want to timeout the user session without activity. After this
+ # time the user will be asked for credentials again.
+ # config.timeout_in = 10.minutes
+
+ # ==> Configuration for :lockable
+ # Defines which strategy will be used to lock an account.
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
+ # :none = No lock strategy. You should handle locking by yourself.
+ # config.lock_strategy = :failed_attempts
+
+ # Defines which strategy will be used to unlock an account.
+ # :email = Sends an unlock link to the user email
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
+ # :both = Enables both strategies
+ # :none = No unlock strategy. You should handle unlocking by yourself.
+ # config.unlock_strategy = :both
+
+ # Number of authentication tries before locking an account if lock_strategy
+ # is failed attempts.
+ # config.maximum_attempts = 20
+
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
+ # config.unlock_in = 1.hour
+
+ # ==> Configuration for :token_authenticatable
+ # Defines name of the authentication token params key
+ # config.token_authentication_key = :auth_token
+
+ # ==> Scopes configuration
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
+ # "users/sessions/new". It's turned off by default because it's slower if you
+ # are using only default views.
+ # config.scoped_views = true
+
+ # Configure the default scope given to Warden. By default it's the first
+ # devise role declared in your routes.
+ # config.default_scope = :user
+
+ # Configure sign_out behavior.
+ # By default sign_out is scoped (i.e. /users/sign_out affects only :user scope).
+ # In case of sign_out_all_scopes set to true any logout action will sign out all active scopes.
+ # config.sign_out_all_scopes = false
+
+ # ==> Navigation configuration
+ # Lists the formats that should be treated as navigational. Formats like
+ # :html, should redirect to the sign in page when the user does not have
+ # access, but formats like :xml or :json, should return 401.
+ # If you have any extra navigational formats, like :iphone or :mobile, you
+ # should add them to the navigational formats lists. Default is [:html]
+ # config.navigational_formats = [:html, :iphone]
+
+ # ==> Warden configuration
+ # If you want to use other strategies, that are not (yet) supported by Devise,
+ # you can configure them inside the config.warden block. The example below
+ # allows you to setup OAuth, using http://github.com/roman/warden_oauth
+ #
+ # config.warden do |manager|
+ # manager.oauth(:twitter) do |twitter|
+ # twitter.consumer_secret = <YOUR CONSUMER SECRET>
+ # twitter.consumer_key = <YOUR CONSUMER KEY>
+ # twitter.options :site => 'http://twitter.com'
+ # end
+ # manager.default_strategies(:scope => :user).unshift :twitter_oauth
+ # end
+end
10 config/initializers/inflections.rb
@@ -0,0 +1,10 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format
+# (all these examples are active by default):
+# ActiveSupport::Inflector.inflections do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
5 config/initializers/mime_types.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
+# Mime::Type.register_alias "text/html", :iphone
3 config/initializers/rails_admin.rb
@@ -0,0 +1,3 @@
+RailsAdmin.config do |c|
+ c.excluded_models << RelTest
+end
7 config/initializers/secret_token.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+DummyApp::Application.config.secret_token = '2e733773e594846c6bb87fe0d0bb8e70ea81d334fccdbceca5b05ede2e61f10ea98add53783bf333d8d5523e001f4d7045d71c57ab288e279626c49b18810f9e'
8 config/initializers/session_store.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+DummyApp::Application.config.session_store :cookie_store, :key => '_dummy_app_session'
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rails generate session_migration")
+# DummyApp::Application.config.session_store :active_record_store
1 config/locales
8 config/routes.rb
@@ -0,0 +1,8 @@
+DummyApp::Application.routes.draw do
+ mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
+ devise_for :users
+ root :to => "rails_admin::Main#index"
+
+ # https://github.com/sferik/rails_admin/issues/362
+ match ':controller(/:action(/:id(.:format)))'
+end
13 db/migrate/00000000000001_create_divisions_migration.rb
@@ -0,0 +1,13 @@
+class CreateDivisionsMigration < ActiveRecord::Migration
+ def self.up
+ create_table :divisions do |t|
+ t.timestamps
+ t.integer :league_id
+ t.string :name, :limit => 50, :null => false
+ end
+ end
+
+ def self.down
+ drop_table(:divisions)
+ end
+end
19 db/migrate/00000000000002_create_drafts_migration.rb
@@ -0,0 +1,19 @@
+class CreateDraftsMigration < ActiveRecord::Migration
+ def self.up
+ create_table :drafts do |t|
+ t.timestamps
+ t.integer :player_id
+ t.integer :team_id
+ t.date :date
+ t.integer :round
+ t.integer :pick
+ t.integer :overall
+ t.string :college, :limit => 100
+ t.text :notes
+ end
+ end
+
+ def self.down
+ drop_table :drafts
+ end
+end
12 db/migrate/00000000000003_create_leagues_migration.rb
@@ -0,0 +1,12 @@
+class CreateLeaguesMigration < ActiveRecord::Migration
+ def self.up
+ create_table :leagues do |t|
+ t.timestamps
+ t.string :name, :limit => 50, :null => false
+ end
+ end
+
+ def self.down
+ drop_table :leagues
+ end
+end
20 db/migrate/00000000000004_create_players_migration.rb
@@ -0,0 +1,20 @@
+class CreatePlayersMigration < ActiveRecord::Migration
+ def self.up
+ create_table :players do |t|
+ t.timestamps
+ t.datetime :deleted_at
+ t.integer :team_id
+ t.string :name, :limit => 100, :null => false
+ t.string :position, :limit => 50
+ t.integer :number, :null => false
+ t.boolean :retired, :default => false
+ t.boolean :injured, :default => false
+ t.date :born_on
+ t.text :notes
+ end
+ end
+
+ def self.down
+ drop_table :players
+ end
+end
22 db/migrate/00000000000005_create_teams_migration.rb
@@ -0,0 +1,22 @@
+class CreateTeamsMigration < ActiveRecord::Migration
+ def self.up
+ create_table :teams do |t|
+ t.timestamps
+ t.integer :league_id
+ t.integer :division_id
+ t.string :name, :limit => 50
+ t.string :logo_url, :limit => 255
+ t.string :manager, :limit => 100, :null => false
+ t.string :ballpark, :limit => 100
+ t.string :mascot, :limit => 100
+ t.integer :founded
+ t.integer :wins
+ t.integer :losses
+ t.float :win_percentage
+ end
+ end
+
+ def self.down
+ drop_table :teams
+ end
+end
19 db/migrate/00000000000006_devise_create_users.rb
@@ -0,0 +1,19 @@
+class DeviseCreateUsers < ActiveRecord::Migration
+ def self.up
+ create_table :users do |t|
+ t.database_authenticatable :null => false
+ t.recoverable
+ t.rememberable
+ t.trackable
+ t.encryptable
+ t.timestamps
+ end
+
+ add_index :users, :email, :unique => true
+ add_index :users, :reset_password_token, :unique => true
+ end
+
+ def self.down
+ drop_table :users
+ end
+end
18 db/migrate/00000000000007_create_histories_table.rb
@@ -0,0 +1,18 @@
+class CreateHistoriesTable < ActiveRecord::Migration
+ def self.up
+ create_table :histories do |t|
+ t.string :message # title, name, or object_id
+ t.string :username
+ t.integer :item
+ t.string :table
+ t.integer :month, :limit => 2
+ t.integer :year, :limit => 5
+ t.timestamps
+ end
+ add_index(:histories, [:item, :table, :month, :year])
+ end
+
+ def self.down
+ drop_table :histories
+ end
+end
12 db/migrate/00000000000008_create_fans_migration.rb
@@ -0,0 +1,12 @@
+class CreateFansMigration < ActiveRecord::Migration
+ def self.up
+ create_table :fans do |t|
+ t.timestamps
+ t.string :name, :limit => 100, :null => false
+ end
+ end
+
+ def self.down
+ drop_table :fans
+ end
+end
11 db/migrate/00000000000009_create_fans_teams_migration.rb
@@ -0,0 +1,11 @@
+class CreateFansTeamsMigration < ActiveRecord::Migration
+ def self.up
+ create_table :fans_teams, :id => false do |t|
+ t.integer :fan_id, :team_id
+ end
+ end
+
+ def self.down
+ drop_table :fans_teams
+ end
+end
9 db/migrate/00000000000010_add_revenue_to_team_migration.rb
@@ -0,0 +1,9 @@
+class AddRevenueToTeamMigration < ActiveRecord::Migration
+ def self.up
+ add_column :teams, :revenue, :decimal, :precision => 18, :scale => 2
+ end
+
+ def self.down
+ remove_column :teams, :revenue
+ end
+end
9 db/migrate/00000000000011_add_suspended_to_player_migration.rb
@@ -0,0 +1,9 @@
+class AddSuspendedToPlayerMigration < ActiveRecord::Migration
+ def self.up
+ add_column :players, :suspended, :boolean, :default => false
+ end
+
+ def self.down
+ remove_column :players, :suspended
+ end
+end
16 db/migrate/00000000000012_add_avatar_columns_to_user.rb
@@ -0,0 +1,16 @@
+ class AddAvatarColumnsToUser < ActiveRecord::Migration
+ def self.up
+ add_column :users, :avatar_file_name, :string
+ add_column :users, :avatar_content_type, :string
+ add_column :users, :avatar_file_size, :integer
+ add_column :users, :avatar_updated_at, :datetime
+ end
+
+ def self.down
+ remove_column :users, :avatar_file_name
+ remove_column :users, :avatar_content_type
+ remove_column :users, :avatar_file_size
+ remove_column :users, :avatar_updated_at
+ end
+ end
+
9 db/migrate/00000000000013_add_roles_to_user.rb
@@ -0,0 +1,9 @@
+ class AddRolesToUser < ActiveRecord::Migration
+ def self.up
+ add_column :users, :roles, :string
+ end
+
+ def self.down
+ remove_column :users, :roles
+ end
+ end
9 db/migrate/00000000000014_add_color_to_team_migration.rb
@@ -0,0 +1,9 @@
+class AddColorToTeamMigration < ActiveRecord::Migration
+ def self.up
+ add_column :teams, :color, :string
+ end
+
+ def self.down
+ remove_column :teams, :color
+ end
+end
15 db/migrate/20101223222233_create_rel_tests.rb
@@ -0,0 +1,15 @@
+class CreateRelTests < ActiveRecord::Migration
+ def self.up
+ create_table :rel_tests do |t|
+ t.integer :league_id
+ t.integer :division_id, :null => false
+ t.integer :player_id
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :rel_tests
+ end
+end
15 db/migrate/20110103205808_create_comments.rb
@@ -0,0 +1,15 @@
+class CreateComments < ActiveRecord::Migration
+ def self.up
+ create_table :comments do |t|
+ t.integer :commentable_id
+ t.string :commentable_type
+ t.text :content
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :comments
+ end
+end
9 db/migrate/20110123042530_rename_histories_to_rails_admin_histories.rb
@@ -0,0 +1,9 @@
+class RenameHistoriesToRailsAdminHistories < ActiveRecord::Migration
+ def self.up
+ rename_table :histories, :rails_admin_histories
+ end
+
+ def self.down
+ rename_table :rails_admin_histories, :histories
+ end
+end
22 db/migrate/20110224184303_create_field_tests.rb
@@ -0,0 +1,22 @@
+class CreateFieldTests < ActiveRecord::Migration
+ def self.up
+ create_table :field_tests do |t|
+ t.string :string_field
+ t.text :text_field
+ t.integer :integer_field
+ t.float :float_field
+ t.decimal :decimal_field
+ t.datetime :datetime_field
+ t.timestamp :timestamp_field
+ t.time :time_field
+ t.date :date_field
+ t.boolean :boolean_field
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :field_tests
+ end
+end
14 db/migrate/20110328193014_create_cms_basic_pages.rb
@@ -0,0 +1,14 @@
+class CreateCmsBasicPages < ActiveRecord::Migration
+ def self.up
+ create_table :cms_basic_pages do |t|
+ t.string :title
+ t.text :content
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :cms_basic_pages
+ end
+end
9 db/migrate/20110329183136_remove_league_id_from_teams.rb
@@ -0,0 +1,9 @@
+class RemoveLeagueIdFromTeams < ActiveRecord::Migration
+ def self.up
+ remove_column :teams, :league_id
+ end
+
+ def self.down
+ add_column :teams, :league_id, :integer
+ end
+end
9 db/migrate/20110607152842_add_format_to_field_test.rb
@@ -0,0 +1,9 @@
+class AddFormatToFieldTest < ActiveRecord::Migration
+ def self.up
+ add_column :field_tests, :format, :string
+ end
+
+ def self.down
+ remove_column :field_tests, :format
+ end
+end
12 db/migrate/20110714095433_create_balls.rb
@@ -0,0 +1,12 @@
+class CreateBalls < ActiveRecord::Migration
+ def self.up
+ create_table :balls, :force => true do |t|
+ t.string :color
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :balls
+ end
+end
6 db/migrate/20110831090841_add_protected_field_and_restricted_field_to_field_tests.rb
@@ -0,0 +1,6 @@
+class AddProtectedFieldAndRestrictedFieldToFieldTests < ActiveRecord::Migration
+ def change
+ add_column :field_tests, :restricted_field, :string
+ add_column :field_tests, :protected_field, :string
+ end
+end
19 db/migrate/20110901131551_change_division_primary_key.rb
@@ -0,0 +1,19 @@
+class ChangeDivisionPrimaryKey < ActiveRecord::Migration
+ def up
+ drop_table :divisions
+ create_table :divisions, :primary_key => 'custom_id' do |t|
+ t.timestamps
+ t.integer :league_id
+ t.string :name, :limit => 50, :null => false
+ end
+ end
+
+ def down
+ drop_table :divisions
+ create_table :divisions do |t|
+ t.timestamps
+ t.integer :league_id
+ t.string :name, :limit => 50, :null => false
+ end
+ end
+end
5 db/migrate/20110901142530_rename_league_id_foreign_key_on_divisions.rb
@@ -0,0 +1,5 @@
+class RenameLeagueIdForeignKeyOnDivisions < ActiveRecord::Migration
+ def change
+ rename_column :divisions, :league_id, :custom_league_id
+ end
+end
21 db/migrate/20110901150912_set_primary_key_not_null_for_divisions.rb
@@ -0,0 +1,21 @@
+class SetPrimaryKeyNotNullForDivisions < ActiveRecord::Migration
+ def up
+ drop_table :divisions
+ create_table :divisions, :id => false do |t|
+ t.timestamps
+ t.primary_key :custom_id
+ t.integer :custom_league_id
+ t.string :name, :limit => 50, :null => false
+ end
+
+ end
+
+ def down
+ drop_table :divisions
+ create_table :divisions, :primary_key => :custom_id do |t|
+ t.timestamps
+ t.integer :custom_league_id
+ t.string :name, :limit => 50, :null => false
+ end
+ end
+end
9 db/migrate/20110901154834_change_length_for_rails_admin_histories.rb
@@ -0,0 +1,9 @@
+class ChangeLengthForRailsAdminHistories < ActiveRecord::Migration
+ def up
+ change_column :rails_admin_histories, :message, :text
+ end
+
+ def down
+ change_column :rails_admin_histories, :message, :string
+ end
+end
18 db/seeds.rb
@@ -0,0 +1,18 @@
+require 'mlb'
+
+User.create(:email => 'username@example.com', :password => 'password', :password_confirmation => 'password')
+
+MLB::Team.all.each do |mlb_team|
+ unless league = RailsAdmin::AbstractModel.new("League").first(:conditions => ["name = ?", mlb_team.league])
+ league = RailsAdmin::AbstractModel.new("League").create(:name => mlb_team.league)
+ end
+ unless division = RailsAdmin::AbstractModel.new("Division").first(:conditions => ["name = ?", mlb_team.division])
+ division = RailsAdmin::AbstractModel.new("Division").create(:name => mlb_team.division, :league => league)
+ end
+ unless team = RailsAdmin::AbstractModel.new("Team").first(:conditions => ["name = ?", mlb_team.name])
+ team = RailsAdmin::AbstractModel.new("Team").create(:name => mlb_team.name, :logo_url => mlb_team.logo_url, :manager => mlb_team.manager, :ballpark => mlb_team.ballpark, :mascot => mlb_team.mascot, :founded => mlb_team.founded, :wins => mlb_team.wins, :losses => mlb_team.losses, :win_percentage => ("%.3f" % (mlb_team.wins.to_f / (mlb_team.wins + mlb_team.losses))).to_f, :division => division)
+ end
+ mlb_team.players.reject{|player| player.number.nil?}.each do |player|
+ RailsAdmin::AbstractModel.new("Player").create(:name => player.name, :number => player.number, :position => player.position, :team => team)
+ end
+end
2 doc/README_FOR_APP
@@ -0,0 +1,2 @@
+Use this README file to introduce your application and point to useful places in the API for learning more.
+Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
0 lib/tasks/.gitkeep
No changes.
1 public
6 script/rails
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
+
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require File.expand_path('../../config/boot', __FILE__)
+require 'rails/commands'
0 vendor/plugins/.gitkeep
No changes.

0 comments on commit 4d43ac2

Please sign in to comment.
Something went wrong with that request. Please try again.