dancroak-sortable_table 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/README.markdown +72 -0
  2. data/Rakefile +9 -9
  3. data/VERSION.yml +4 -0
  4. data/lib/sortable_table/app/controllers/application_controller.rb +15 -47
  5. data/lib/sortable_table/app/helpers/application_helper.rb +47 -31
  6. data/lib/sortable_table/test/test_helper.rb +65 -0
  7. data/lib/sortable_table.rb +1 -0
  8. data/test/rails_root/Rakefile +10 -0
  9. data/test/rails_root/app/controllers/application.rb +5 -0
  10. data/test/rails_root/app/controllers/users_controller.rb +9 -0
  11. data/test/rails_root/app/helpers/application_helper.rb +3 -0
  12. data/test/rails_root/app/helpers/users_helper.rb +2 -0
  13. data/test/rails_root/app/models/user.rb +2 -0
  14. data/test/rails_root/app/views/layouts/users.html.erb +17 -0
  15. data/test/rails_root/app/views/users/index.html.erb +19 -0
  16. data/test/rails_root/config/boot.rb +109 -0
  17. data/test/rails_root/config/database.yml +19 -0
  18. data/test/rails_root/config/environment.rb +26 -0
  19. data/test/rails_root/config/environments/development.rb +17 -0
  20. data/test/rails_root/config/environments/test.rb +22 -0
  21. data/test/rails_root/config/initializers/new_rails_defaults.rb +15 -0
  22. data/test/rails_root/config/routes.rb +6 -0
  23. data/test/rails_root/db/development.sqlite3 +0 -0
  24. data/test/rails_root/db/migrate/20080819225020_create_users.rb +15 -0
  25. data/test/rails_root/db/production.sqlite3 +0 -0
  26. data/test/rails_root/db/schema.rb +23 -0
  27. data/test/rails_root/db/test.sqlite3 +0 -0
  28. data/test/rails_root/log/development.log +2710 -0
  29. data/test/rails_root/log/production.log +0 -0
  30. data/test/rails_root/log/server.log +0 -0
  31. data/test/rails_root/public/404.html +30 -0
  32. data/test/rails_root/public/422.html +30 -0
  33. data/test/rails_root/public/500.html +30 -0
  34. data/test/rails_root/public/dispatch.cgi +10 -0
  35. data/test/rails_root/public/dispatch.fcgi +24 -0
  36. data/test/rails_root/public/dispatch.rb +10 -0
  37. data/test/rails_root/public/favicon.ico +0 -0
  38. data/test/rails_root/public/images/rails.png +0 -0
  39. data/test/rails_root/public/images/sort-ascending-arrow.gif +0 -0
  40. data/test/rails_root/public/images/sort-descending-arrow.gif +0 -0
  41. data/test/rails_root/public/index.html +274 -0
  42. data/test/rails_root/public/javascripts/application.js +2 -0
  43. data/test/rails_root/public/javascripts/controls.js +963 -0
  44. data/test/rails_root/public/javascripts/dragdrop.js +972 -0
  45. data/test/rails_root/public/javascripts/effects.js +1120 -0
  46. data/test/rails_root/public/javascripts/prototype.js +4225 -0
  47. data/test/rails_root/public/robots.txt +5 -0
  48. data/test/rails_root/public/stylesheets/scaffold.css +53 -0
  49. data/test/rails_root/public/stylesheets/sortable.css +10 -0
  50. data/test/rails_root/script/about +3 -0
  51. data/test/rails_root/script/console +3 -0
  52. data/test/rails_root/script/dbconsole +3 -0
  53. data/test/rails_root/script/destroy +3 -0
  54. data/test/rails_root/script/generate +3 -0
  55. data/test/rails_root/script/performance/benchmarker +3 -0
  56. data/test/rails_root/script/performance/profiler +3 -0
  57. data/test/rails_root/script/performance/request +3 -0
  58. data/test/rails_root/script/plugin +3 -0
  59. data/test/rails_root/script/process/inspector +3 -0
  60. data/test/rails_root/script/process/reaper +3 -0
  61. data/test/rails_root/script/process/spawner +3 -0
  62. data/test/rails_root/script/runner +3 -0
  63. data/test/rails_root/script/server +3 -0
  64. data/test/rails_root/test/factories/user_factory.rb +17 -0
  65. data/test/rails_root/test/functional/users_controller_test.rb +15 -0
  66. data/test/rails_root/test/test_helper.rb +32 -0
  67. data/test/rails_root/test/units/helpers/application_helper_test.rb +46 -0
  68. metadata +220 -4
  69. data/README.textile +0 -136
  70. data/TODO.textile +0 -2
data/README.markdown ADDED
@@ -0,0 +1,72 @@
1
+ Sortable Table
2
+ ==============
3
+
4
+ Rails plugin to sort tables of ActiveRecord data.
5
+
6
+ Install
7
+ -------
8
+
9
+ script/plugin install git://github.com/dancroak/sortable_table.git
10
+
11
+ Conventions
12
+ -----------
13
+
14
+ params[:sort] and params[:order]
15
+
16
+ Examples
17
+ --------
18
+
19
+ Use the sortable_attributes macro to list the... sortable attributes.
20
+
21
+ Then, in your index action, pass the sort_order method to your usual
22
+ order parameter for will paginate or named scope call.
23
+
24
+ class UsersController < Admin::BaseController
25
+
26
+ sortable_attributes :name, :email
27
+
28
+ def index
29
+ @users = User.paginate :page => params[:page], :order => sort_order
30
+ end
31
+
32
+ end
33
+
34
+ Time-saving Shoulda macros for your tests:
35
+
36
+ class UsersControllerTest < ActionController::TestCase
37
+
38
+ context 'GET to index with sort and order params' do
39
+ setup do
40
+ 5.times do |each|
41
+ Factory :user,
42
+ :name => "name #{each}",
43
+ :email => "email#{each}@example.com"
44
+ end
45
+ end
46
+
47
+ should_sort_by :name
48
+ should_sort_by :email
49
+ end
50
+
51
+ end
52
+
53
+ And some sugar for your views:
54
+
55
+ %h1 Users
56
+
57
+ %table
58
+ %tr
59
+ = sortable_table_header 'Name', :sort => 'name'
60
+ = sortable_table_header 'E-mail', :sort => 'email'
61
+
62
+ - @users.each do |each|
63
+ %tr
64
+ %td= each.name
65
+ %td= each.email
66
+
67
+ Authors
68
+ -------
69
+
70
+ Dan Croak, Joe Ferris, and Boston.rb.
71
+
72
+ Copyright (c) 2008 Dan Croak, released under the MIT license
data/Rakefile CHANGED
@@ -11,21 +11,21 @@ end
11
11
 
12
12
  desc "Run the test suite"
13
13
  task :default => :test
14
-
14
+
15
15
  spec = Gem::Specification.new do |s|
16
- s.version = '0.0.4'
17
16
  s.name = "sortable_table"
18
17
  s.summary = "Sort HTML tables in a Rails app."
19
18
  s.email = "dcroak@thoughtbot.com"
20
19
  s.homepage = "http://github.com/dancroak/sortable_table"
21
20
  s.description = "Sort HTML tables in a Rails app."
22
21
  s.authors = ["Dan Croak", "Joe Ferris", "Boston.rb"]
23
- s.files = FileList["[A-Z]*", "{lib,rails}/**/*"]
22
+ s.files = FileList["[A-Z]*", "{lib,rails,test}/**/*"]
24
23
  end
25
-
26
- desc "Generate a gemspec file"
27
- task :gemspec do
28
- File.open("#{spec.name}.gemspec", 'w') do |f|
29
- f.write spec.to_yaml
30
- end
24
+
25
+ begin
26
+ require 'rubygems'
27
+ require 'jeweler'
28
+ Jeweler.gemspec = spec
29
+ rescue LoadError
30
+ puts "Jeweler not available. sudo gem install technicalpickles-jeweler --source=http://gems.github.com"
31
31
  end
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ patch: 0
3
+ major: 0
4
+ minor: 1
@@ -2,7 +2,7 @@ module SortableTable
2
2
  module App
3
3
  module Controllers
4
4
  module ApplicationController
5
-
5
+
6
6
  def self.included(base)
7
7
  base.class_eval do
8
8
  include InstanceMethods
@@ -12,33 +12,21 @@ module SortableTable
12
12
 
13
13
  module ClassMethods
14
14
  def sortable_attributes(*args)
15
- mappings = pop_hash_from_list(args)
16
- acceptable_columns = join_array_and_hash_values(args, mappings)
17
- define_sort_order(acceptable_columns, mappings)
18
- end
19
-
20
- def pop_hash_from_list(*args)
21
- if args.last.is_a?(Hash)
22
- args.pop
23
- else
24
- {}
25
- end
26
- end
27
-
28
- def join_array_and_hash_values(array, hash)
29
- array.collect { |each| each.to_s } +
30
- hash.values.collect { |each| each.to_s }
31
- end
32
-
33
- def define_sort_order(acceptable_columns, mappings)
15
+ mappings = args.last.is_a?(Hash) ? args.pop : {}
16
+ acceptable_columns = args.collect(&:to_s) + mappings.keys.collect(&:to_s)
17
+
34
18
  define_method(:sort_order) do |*default|
35
- direction = params[:order] == 'ascending' ? 'asc' : 'desc'
36
- column = params[:sort] || acceptable_columns.first
19
+ direction = if params[:order]
20
+ params[:order] == 'ascending' ? 'asc' : 'desc'
21
+ else
22
+ default_sort_direction(default)
23
+ end
24
+ column = params[:sort] || 'created_at'
37
25
  if params[:sort] && acceptable_columns.include?(column)
38
26
  column = mappings[column.to_sym] || column
39
- handle_compound_sorting(column, direction)
27
+ "#{column} #{direction}"
40
28
  else
41
- "#{acceptable_columns.first} #{default_sort_direction(default)}"
29
+ "#{acceptable_columns.first} #{direction}"
42
30
  end
43
31
  end
44
32
  end
@@ -46,30 +34,10 @@ module SortableTable
46
34
 
47
35
  module InstanceMethods
48
36
  def default_sort_direction(default)
49
- if hash_with_default_key?(default)
50
- case default.first[:default]
51
- when "ascending", "asc" then "asc"
52
- when "descending", "asc" then "desc"
53
- else
54
- raise RuntimeError,
55
- "valid :default sort orders are 'ascending' & 'descending'"
56
- end
57
- else
58
- "desc"
59
- end
60
- end
61
-
62
- def hash_with_default_key?(object)
63
- object.any? &&
64
- object.first.is_a?(Hash) &&
65
- object.first.has_key?(:default)
66
- end
67
-
68
- def handle_compound_sorting(column, direction)
69
- if column.is_a?(Array)
70
- column.collect { |each| "#{each} #{direction}" }.join(',')
37
+ if default.any? && default.first.is_a?(Hash) && default.first.has_key?(:default)
38
+ default.first[:default] == 'ascending' ? 'asc' : 'desc'
71
39
  else
72
- "#{column} #{direction}"
40
+ 'desc'
73
41
  end
74
42
  end
75
43
  end
@@ -10,49 +10,53 @@ module SortableTable
10
10
  end
11
11
 
12
12
  module InstanceMethods
13
- def sortable_table_header(opts = {})
14
- raise ArgumentError if opts[:name].nil? || opts[:sort].nil?
15
- anchor = opts[:anchor].blank? ? "" : "##{opts[:anchor]}"
13
+ def sortable_table_header(*args)
14
+ opts = args.extract_options!
15
+
16
+ inner_html = args
17
+ if inner_html.blank?
18
+ raise ArgumentError("Must specify inner_html as first argument")
19
+ end
20
+
21
+ # if args.first.is_a?(String)
22
+ # inner_html = args.shift
23
+ # elsif opts.first.is_a?(Hash)
24
+ # if opts.has_key?(:inner_html)
25
+ # inner_html = opts[:inner_html]
26
+ # else
27
+ # # raise ArgumentError unless opts.has_key?(:sort)
28
+ # inner_html = opts[:sort].humanize
29
+ # end
30
+ # else
31
+ # raise ArgumentError,
32
+ # "calling signature must be String, Hash or Hash"
33
+ # end
34
+
35
+ # anchor = opts[:anchor].blank? ? "" : "##{opts[:anchor]}"
36
+ # sortable_url(opts) + anchor
37
+
16
38
  content_tag :th,
17
- link_to(opts[:name],
18
- sortable_url(opts) + anchor,
39
+ link_to(inner_html,
40
+ sortable_url(opts),
19
41
  :title => opts[:title]),
20
- :class => sortable_table_header_classes(opts)
42
+ :class => class_name_for_sortable_table_header_tag(opts)
21
43
  end
22
44
 
23
- def sortable_table_header_classes(opts)
24
- class_names = []
25
- class_names << sortable_table_header_class(opts)
26
- class_names << opts[:class]
27
- class_names.compact.blank? ? nil : class_names.compact.join(" ")
28
- end
29
-
30
- def sortable_table_header_class(opts)
45
+ def class_name_for_sortable_table_header_tag(opts)
31
46
  if default_sort_to_most_recent? opts
32
- 'descending'
47
+ class_name = 'descending'
33
48
  elsif re_sort? opts
34
- params[:order]
49
+ class_name = params[:order]
35
50
  else
36
- nil
51
+ class_name = ""
37
52
  end
53
+ class_name << " #{opts[:class_name]}"
38
54
  end
39
-
40
- def default_sort_to_most_recent?(opts)
41
- params[:sort].nil? && opts[:sort] == 'date'
42
- end
43
-
44
- def re_sort?(opts)
45
- params[:sort] == opts[:sort]
46
- end
47
-
48
- def reverse_order(order)
49
- order == 'ascending' ? 'descending' : 'ascending'
50
- end
51
-
55
+
52
56
  def sortable_url(opts)
53
57
  url_for(params.merge(:sort => opts[:sort], :order => link_sort_order(opts), :page => 1))
54
58
  end
55
-
59
+
56
60
  def link_sort_order(opts)
57
61
  if default_sort_to_most_recent? opts
58
62
  'ascending'
@@ -62,6 +66,18 @@ module SortableTable
62
66
  'ascending'
63
67
  end
64
68
  end
69
+
70
+ def default_sort_to_most_recent?(opts)
71
+ params[:sort].nil? && opts[:sort] == @sorted_column
72
+ end
73
+
74
+ def re_sort?(opts)
75
+ params[:sort] == opts[:sort]
76
+ end
77
+
78
+ def reverse_order(order)
79
+ order == 'ascending' ? 'descending' : 'ascending'
80
+ end
65
81
  end
66
82
 
67
83
  end
@@ -0,0 +1,65 @@
1
+ module SortableTable
2
+ module Test
3
+ module TestHelper
4
+
5
+ def self.included(base)
6
+ base.class_eval do
7
+ include InstanceMethods
8
+ extend ClassMethods
9
+ end
10
+ end
11
+
12
+ module InstanceMethods
13
+ def stubbed_action_view
14
+ view = ActionView::Base.new(@controller.class.view_paths, {}, @controller)
15
+ yield view
16
+ ActionView::Base.stubs(:new).returns(view)
17
+ end
18
+ end
19
+
20
+ module ClassMethods
21
+ def should_sort_by(attribute, params = {}, &block)
22
+ collection = self.name.underscore.gsub(/_controller_test/, '')
23
+ collection.slice!(0..collection.rindex('/')) if collection.include?('/')
24
+ collection = collection.to_sym
25
+ model_name = collection.to_s.singularize.camelize.constantize
26
+ block ||= attribute
27
+
28
+ %w(ascending descending).each do |direction|
29
+ should "sort by #{attribute.to_s} #{direction}" do
30
+ assert_not_nil model_name.find(:all).any?,
31
+ "#{model_name}.find(:all) is nil"
32
+
33
+ get :index, :sort => attribute.to_s, :order => direction
34
+
35
+ # controller tests
36
+
37
+ assert_not_nil assigns(collection),
38
+ "assigns(:#{collection}) is nil"
39
+ assert assigns(collection).size >= 2,
40
+ "cannot test sorting without at least 2 sortable objects"
41
+
42
+ expected = assigns(collection).sort_by(&block)
43
+ expected = expected.reverse if direction == 'descending'
44
+
45
+ assert expected == assigns(collection),
46
+ "expected - #{expected.map(&block).inspect}," <<
47
+ " but was - #{assigns(collection).map(&block).inspect}"
48
+
49
+ # view tests
50
+
51
+ view_helper_error_message = "Include the sortable_table_header" <<
52
+ " helper in your view with the option :sort => '#{attribute}'"
53
+
54
+ assert_select "th" do
55
+ assert_select "a[href*=?]", "sort=#{attribute.to_s}",
56
+ true, view_helper_error_message
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -1,2 +1,3 @@
1
1
  require "sortable_table/app/controllers/application_controller"
2
2
  require "sortable_table/app/helpers/application_helper"
3
+ require "sortable_table/test/test_helper"
@@ -0,0 +1,10 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5
+
6
+ require 'rake'
7
+ require 'rake/testtask'
8
+ require 'rake/rdoctask'
9
+
10
+ require 'tasks/rails'
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ helper :all
3
+ protect_from_forgery
4
+ include SortableTable::App::Controllers::ApplicationController
5
+ end
@@ -0,0 +1,9 @@
1
+ class UsersController < ApplicationController
2
+
3
+ sortable_attributes :name, :age, :email => 'users.email'
4
+
5
+ def index
6
+ @users = User.find :all#, :order => sort_order('ascending')
7
+ end
8
+
9
+ end
@@ -0,0 +1,3 @@
1
+ module ApplicationHelper
2
+ include SortableTable::App::Helpers::ApplicationHelper
3
+ end
@@ -0,0 +1,2 @@
1
+ module UsersHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class User < ActiveRecord::Base
2
+ end
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title>Users: <%= controller.action_name %></title>
8
+ <%= stylesheet_link_tag 'scaffold', 'sortable' %>
9
+ </head>
10
+ <body>
11
+
12
+ <p style="color: green"><%= flash[:notice] %></p>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,19 @@
1
+ <h1>Users</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <%= sortable_table_header 'Name', :sort => 'name' %>
6
+ <%= sortable_table_header 'Email', :sort => 'email' %>
7
+ <%= sortable_table_header 'Age', :sort => 'age' %>
8
+ <th>Created On</th>
9
+ </tr>
10
+
11
+ <% @users.each do |user| %>
12
+ <tr>
13
+ <td><%=h user.name %></td>
14
+ <td><%=h user.email %></td>
15
+ <td><%=h user.age %></td>
16
+ <td><%=h user.created_at.to_s %></td>
17
+ </tr>
18
+ <% end %>
19
+ </table>
@@ -0,0 +1,109 @@
1
+ # Don't change this file!
2
+ # Configure your app in config/environment.rb and config/environments/*.rb
3
+
4
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
+
6
+ module Rails
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ preinitialize
11
+ pick_boot.run
12
+ end
13
+ end
14
+
15
+ def booted?
16
+ defined? Rails::Initializer
17
+ end
18
+
19
+ def pick_boot
20
+ (vendor_rails? ? VendorBoot : GemBoot).new
21
+ end
22
+
23
+ def vendor_rails?
24
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
25
+ end
26
+
27
+ def preinitialize
28
+ load(preinitializer_path) if File.exist?(preinitializer_path)
29
+ end
30
+
31
+ def preinitializer_path
32
+ "#{RAILS_ROOT}/config/preinitializer.rb"
33
+ end
34
+ end
35
+
36
+ class Boot
37
+ def run
38
+ load_initializer
39
+ Rails::Initializer.run(:set_load_path)
40
+ end
41
+ end
42
+
43
+ class VendorBoot < Boot
44
+ def load_initializer
45
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
+ Rails::Initializer.run(:install_gem_spec_stubs)
47
+ end
48
+ end
49
+
50
+ class GemBoot < Boot
51
+ def load_initializer
52
+ self.class.load_rubygems
53
+ load_rails_gem
54
+ require 'initializer'
55
+ end
56
+
57
+ def load_rails_gem
58
+ if version = self.class.gem_version
59
+ gem 'rails', version
60
+ else
61
+ gem 'rails'
62
+ end
63
+ rescue Gem::LoadError => load_error
64
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
65
+ exit 1
66
+ end
67
+
68
+ class << self
69
+ def rubygems_version
70
+ Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
71
+ end
72
+
73
+ def gem_version
74
+ if defined? RAILS_GEM_VERSION
75
+ RAILS_GEM_VERSION
76
+ elsif ENV.include?('RAILS_GEM_VERSION')
77
+ ENV['RAILS_GEM_VERSION']
78
+ else
79
+ parse_gem_version(read_environment_rb)
80
+ end
81
+ end
82
+
83
+ def load_rubygems
84
+ require 'rubygems'
85
+
86
+ unless rubygems_version >= '0.9.4'
87
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
88
+ exit 1
89
+ end
90
+
91
+ rescue LoadError
92
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
93
+ exit 1
94
+ end
95
+
96
+ def parse_gem_version(text)
97
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
98
+ end
99
+
100
+ private
101
+ def read_environment_rb
102
+ File.read("#{RAILS_ROOT}/config/environment.rb")
103
+ end
104
+ end
105
+ end
106
+ end
107
+
108
+ # All that for this:
109
+ Rails.boot!
@@ -0,0 +1,19 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ timeout: 5000
7
+
8
+ # Warning: The database defined as "test" will be erased and
9
+ # re-generated from your development database when you run "rake".
10
+ # Do not set this db to the same as development or production.
11
+ test:
12
+ adapter: sqlite3
13
+ database: db/test.sqlite3
14
+ timeout: 5000
15
+
16
+ production:
17
+ adapter: sqlite3
18
+ database: db/production.sqlite3
19
+ timeout: 5000
@@ -0,0 +1,26 @@
1
+ # Be sure to restart your server when you modify this file
2
+
3
+ # Uncomment below to force Rails into production mode when
4
+ # you don't control web/app server and can't set it the proper way
5
+ # ENV['RAILS_ENV'] ||= 'production'
6
+
7
+ # Specifies gem version of Rails to use when vendor/rails is not present
8
+ RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION
9
+
10
+ # Bootstrap the Rails environment, frameworks, and default configuration
11
+ require File.join(File.dirname(__FILE__), 'boot')
12
+
13
+ Rails::Initializer.run do |config|
14
+
15
+ config.time_zone = 'UTC'
16
+
17
+ # Your secret key for verifying cookie session data integrity.
18
+ # If you change this key, all old sessions will become invalid!
19
+ # Make sure the secret is at least 30 characters and all random,
20
+ # no regular words or you'll be exposed to dictionary attacks.
21
+ config.action_controller.session = {
22
+ :session_key => '_rails_root_session',
23
+ :secret => '6042b566bbfa8e55bdb33a4b3b39b3c373e035c0a87b587a614db4c8bfea19a7adbd49f2098d4c995e37b28f6539e309f4bc5885cf023b47d5fe9d4450be2d46'
24
+ }
25
+
26
+ end
@@ -0,0 +1,17 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # In the development environment your application's code is reloaded on
4
+ # every request. This slows down response time but is perfect for development
5
+ # since you don't have to restart the webserver when you make code changes.
6
+ config.cache_classes = false
7
+
8
+ # Log error messages when you accidentally call methods on nil.
9
+ config.whiny_nils = true
10
+
11
+ # Show full error reports and disable caching
12
+ config.action_controller.consider_all_requests_local = true
13
+ config.action_view.debug_rjs = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,22 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+ config.cache_classes = true
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.action_controller.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Disable request forgery protection in test environment
17
+ config.action_controller.allow_forgery_protection = false
18
+
19
+ # Tell Action Mailer not to deliver emails to the real world.
20
+ # The :test delivery method accumulates sent emails in the
21
+ # ActionMailer::Base.deliveries array.
22
+ config.action_mailer.delivery_method = :test
@@ -0,0 +1,15 @@
1
+ # These settings change the behavior of Rails 2 apps and will be defaults
2
+ # for Rails 3. You can remove this initializer when Rails 3 is released.
3
+
4
+ # Include Active Record class name as root for JSON serialized output.
5
+ ActiveRecord::Base.include_root_in_json = true
6
+
7
+ # Store the full class name (including module namespace) in STI type column.
8
+ ActiveRecord::Base.store_full_sti_class = true
9
+
10
+ # Use ISO 8601 format for JSON serialized times and dates.
11
+ ActiveSupport.use_standard_json_time_format = true
12
+
13
+ # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
14
+ # if you're including raw json in an HTML page.
15
+ ActiveSupport.escape_html_entities_in_json = false
@@ -0,0 +1,6 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ map.resources :users
3
+
4
+ map.connect ':controller/:action/:id'
5
+ map.connect ':controller/:action/:id.:format'
6
+ end