to_spreadsheet 0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +24 -0
- data/README +48 -0
- data/Rakefile +21 -0
- data/lib/to_spreadsheet/action_pack_renderers.rb +21 -0
- data/lib/to_spreadsheet/mime_types.rb +2 -0
- data/lib/to_spreadsheet/version.rb +3 -0
- data/lib/to_spreadsheet/xls.rb +23 -0
- data/lib/to_spreadsheet.rb +7 -0
- data/test/test_app/Gemfile +10 -0
- data/test/test_app/Gemfile.lock +88 -0
- data/test/test_app/README +1 -0
- data/test/test_app/Rakefile +7 -0
- data/test/test_app/app/controllers/application_controller.rb +3 -0
- data/test/test_app/app/controllers/contacts_controller.rb +7 -0
- data/test/test_app/app/models/contact.rb +3 -0
- data/test/test_app/app/views/contacts/_table.erb +24 -0
- data/test/test_app/app/views/contacts/index.html.erb +1 -0
- data/test/test_app/app/views/contacts/index.xls.erb +1 -0
- data/test/test_app/app/views/layouts/application.html.erb +7 -0
- data/test/test_app/config/application.rb +15 -0
- data/test/test_app/config/boot.rb +6 -0
- data/test/test_app/config/database.yml +22 -0
- data/test/test_app/config/environment.rb +5 -0
- data/test/test_app/config/environments/development.rb +26 -0
- data/test/test_app/config/environments/production.rb +49 -0
- data/test/test_app/config/environments/test.rb +35 -0
- data/test/test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/test_app/config/initializers/inflections.rb +10 -0
- data/test/test_app/config/initializers/mime_types.rb +5 -0
- data/test/test_app/config/initializers/secret_token.rb +7 -0
- data/test/test_app/config/initializers/session_store.rb +8 -0
- data/test/test_app/config/locales/en.yml +5 -0
- data/test/test_app/config/routes.rb +4 -0
- data/test/test_app/config.ru +4 -0
- data/test/test_app/db/development.sqlite3 +0 -0
- data/test/test_app/db/migrate/01_create_contacts.rb +15 -0
- data/test/test_app/db/schema.rb +21 -0
- data/test/test_app/db/seeds.rb +7 -0
- data/test/test_app/db/test.sqlite3 +0 -0
- data/test/test_app/log/development.log +509 -0
- data/test/test_app/log/production.log +0 -0
- data/test/test_app/log/server.log +0 -0
- data/test/test_app/log/test.log +104 -0
- data/test/test_app/script/rails +6 -0
- data/test/test_app/test/fixtures/contacts.yml +5 -0
- data/test/test_app/test/integration/rails_integration_test.rb +14 -0
- data/test/test_app/test/test_helper.rb +7 -0
- data/test/test_app/test/unit/contact_test.rb +7 -0
- data/test/test_helper.rb +1 -0
- metadata +153 -0
data/LICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
LICENSE
|
2
|
+
|
3
|
+
The MIT License
|
4
|
+
|
5
|
+
Copyright 2011 Gleb Mazovetskiy
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
8
|
+
a copy of this software and associated documentation files (the
|
9
|
+
"Software"), to deal in the Software without restriction, including
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
+
permit persons to whom the Software is furnished to do so, subject to
|
13
|
+
the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be
|
16
|
+
included in all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
to_spreadsheet is a gem that lets you render xls from your existing haml/erb views from Rails (>= 3.0).
|
2
|
+
|
3
|
+
= Installation
|
4
|
+
|
5
|
+
Add it to your Gemfile:
|
6
|
+
|
7
|
+
gem 'to_spreadsheet'
|
8
|
+
|
9
|
+
|
10
|
+
= Usage
|
11
|
+
|
12
|
+
In your controller:
|
13
|
+
|
14
|
+
class MyThingiesController < ApplicationController
|
15
|
+
respond_to :xls, :html
|
16
|
+
|
17
|
+
def index
|
18
|
+
@my_thingies = MyThing.all
|
19
|
+
respond_with(@my_thingies)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
In your view partial:
|
24
|
+
|
25
|
+
# _my_thingies.haml
|
26
|
+
%table
|
27
|
+
%caption My thingies
|
28
|
+
%thead
|
29
|
+
%tr
|
30
|
+
%td ID
|
31
|
+
%td Name
|
32
|
+
%tbody
|
33
|
+
- @my_thingies.each do |thingie|
|
34
|
+
%tr
|
35
|
+
%td.number= thingie.id
|
36
|
+
%td= thingie.name
|
37
|
+
%tfoot
|
38
|
+
%tr
|
39
|
+
%td(colspan="2") #{@my_thingies.length}
|
40
|
+
|
41
|
+
In your index.xls.haml:
|
42
|
+
|
43
|
+
= render :partial => '_my_thingies', :collection => @my_thingies
|
44
|
+
|
45
|
+
In your index.html.haml:
|
46
|
+
|
47
|
+
= link_to 'Download XLS', my_thingies_url(:format => :xls)
|
48
|
+
= render :partial => '_my_thingies', :collection => @my_thingies
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rake'
|
10
|
+
require 'rake/rdoctask'
|
11
|
+
|
12
|
+
require 'rake/testtask'
|
13
|
+
|
14
|
+
Rake::TestTask.new(:test) do |t|
|
15
|
+
Dir.chdir('test/test_app')
|
16
|
+
Kernel.exec('rake db:test:prepare')
|
17
|
+
Kernel.exec('rake test')
|
18
|
+
Dir.chdir('../..')
|
19
|
+
end
|
20
|
+
|
21
|
+
task :default => :test
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'action_controller/metal/renderers'
|
2
|
+
require 'action_controller/metal/responder'
|
3
|
+
|
4
|
+
require 'to_spreadsheet/xls'
|
5
|
+
|
6
|
+
# This will let us do thing like `render :xls => 'index'`
|
7
|
+
# This is also how Rails internally implements its :json and :xml renderers
|
8
|
+
# Rarely used, nevertheless public API
|
9
|
+
ActionController::Renderers.add :xls do |template, options|
|
10
|
+
send_data ToSpreadsheet::XLS.to_io(render_to_string(template, options)).read, :type => :xls
|
11
|
+
end
|
12
|
+
|
13
|
+
class ActionController::Responder
|
14
|
+
# This sets up a default render call for when you do
|
15
|
+
# respond_to do |format|
|
16
|
+
# format.xls
|
17
|
+
# end
|
18
|
+
def to_xls
|
19
|
+
controller.render :xls => controller.action_name
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ToSpreadsheet
|
2
|
+
require 'spreadsheet'
|
3
|
+
module XLS
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def to_io(html)
|
7
|
+
spreadsheet = Spreadsheet::Workbook.new
|
8
|
+
Nokogiri::XML::Document.parse(html).xpath('/table').each_with_index do |xml_table, i|
|
9
|
+
sheet = spreadsheet.create_worksheet(:name => xml_table.css('caption').inner_text.presence || "Sheet #{i + 1}")
|
10
|
+
xml_table.css('tr').each_with_index do |row_node, row|
|
11
|
+
row_node.css('th,td').each_with_index do |col_node, col|
|
12
|
+
text = col_node.inner_text
|
13
|
+
sheet[row,col] = text
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
io = StringIO.new
|
18
|
+
spreadsheet.write(io)
|
19
|
+
io.rewind
|
20
|
+
io
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../..
|
3
|
+
specs:
|
4
|
+
spreadsheet_renderer (0.9)
|
5
|
+
nokogiri
|
6
|
+
rails
|
7
|
+
spreadsheet
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
abstract (1.0.0)
|
13
|
+
actionmailer (3.0.5)
|
14
|
+
actionpack (= 3.0.5)
|
15
|
+
mail (~> 2.2.15)
|
16
|
+
actionpack (3.0.5)
|
17
|
+
activemodel (= 3.0.5)
|
18
|
+
activesupport (= 3.0.5)
|
19
|
+
builder (~> 2.1.2)
|
20
|
+
erubis (~> 2.6.6)
|
21
|
+
i18n (~> 0.4)
|
22
|
+
rack (~> 1.2.1)
|
23
|
+
rack-mount (~> 0.6.13)
|
24
|
+
rack-test (~> 0.5.7)
|
25
|
+
tzinfo (~> 0.3.23)
|
26
|
+
activemodel (3.0.5)
|
27
|
+
activesupport (= 3.0.5)
|
28
|
+
builder (~> 2.1.2)
|
29
|
+
i18n (~> 0.4)
|
30
|
+
activerecord (3.0.5)
|
31
|
+
activemodel (= 3.0.5)
|
32
|
+
activesupport (= 3.0.5)
|
33
|
+
arel (~> 2.0.2)
|
34
|
+
tzinfo (~> 0.3.23)
|
35
|
+
activeresource (3.0.5)
|
36
|
+
activemodel (= 3.0.5)
|
37
|
+
activesupport (= 3.0.5)
|
38
|
+
activesupport (3.0.5)
|
39
|
+
arel (2.0.9)
|
40
|
+
builder (2.1.2)
|
41
|
+
erubis (2.6.6)
|
42
|
+
abstract (>= 1.0.0)
|
43
|
+
i18n (0.5.0)
|
44
|
+
mail (2.2.15)
|
45
|
+
activesupport (>= 2.3.6)
|
46
|
+
i18n (>= 0.4.0)
|
47
|
+
mime-types (~> 1.16)
|
48
|
+
treetop (~> 1.4.8)
|
49
|
+
mime-types (1.16)
|
50
|
+
mocha (0.9.12)
|
51
|
+
nokogiri (1.4.4.1-x86-mingw32)
|
52
|
+
polyglot (0.3.1)
|
53
|
+
rack (1.2.2)
|
54
|
+
rack-mount (0.6.13)
|
55
|
+
rack (>= 1.0.0)
|
56
|
+
rack-test (0.5.7)
|
57
|
+
rack (>= 1.0)
|
58
|
+
rails (3.0.5)
|
59
|
+
actionmailer (= 3.0.5)
|
60
|
+
actionpack (= 3.0.5)
|
61
|
+
activerecord (= 3.0.5)
|
62
|
+
activeresource (= 3.0.5)
|
63
|
+
activesupport (= 3.0.5)
|
64
|
+
bundler (~> 1.0)
|
65
|
+
railties (= 3.0.5)
|
66
|
+
railties (3.0.5)
|
67
|
+
actionpack (= 3.0.5)
|
68
|
+
activesupport (= 3.0.5)
|
69
|
+
rake (>= 0.8.7)
|
70
|
+
thor (~> 0.14.4)
|
71
|
+
rake (0.8.7)
|
72
|
+
ruby-ole (1.2.11.1)
|
73
|
+
spreadsheet (0.6.5.2)
|
74
|
+
ruby-ole (>= 1.0)
|
75
|
+
sqlite3 (1.3.3-x86-mingw32)
|
76
|
+
thor (0.14.6)
|
77
|
+
treetop (1.4.9)
|
78
|
+
polyglot (>= 0.3.1)
|
79
|
+
tzinfo (0.3.25)
|
80
|
+
|
81
|
+
PLATFORMS
|
82
|
+
x86-mingw32
|
83
|
+
|
84
|
+
DEPENDENCIES
|
85
|
+
mocha
|
86
|
+
rails (> 3)
|
87
|
+
spreadsheet_renderer!
|
88
|
+
sqlite3
|
@@ -0,0 +1 @@
|
|
1
|
+
Test app for rails_spreadsheet gem
|
@@ -0,0 +1,7 @@
|
|
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.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
TestApp::Application.load_tasks
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<table>
|
2
|
+
<caption>Test caption</caption>
|
3
|
+
<thead>
|
4
|
+
<tr>
|
5
|
+
<th>Name</th>
|
6
|
+
<th>Website</th>
|
7
|
+
<th>Age</th>
|
8
|
+
</tr>
|
9
|
+
</thead>
|
10
|
+
<tbody>
|
11
|
+
<% contacts.each do |contact| %>
|
12
|
+
<tr>
|
13
|
+
<td><%= contact.name %></td>
|
14
|
+
<td><%= contact.website %></td>
|
15
|
+
<td><%= contact.age %></td>
|
16
|
+
</tr>
|
17
|
+
<% end %>
|
18
|
+
</tbody>
|
19
|
+
<tfoot>
|
20
|
+
<tr>
|
21
|
+
<td>footer stuff</td>
|
22
|
+
</tr>
|
23
|
+
</tfoot>
|
24
|
+
</table>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'contacts/table', :contacts => @contacts %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'contacts/table', :contacts => @contacts %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
6
|
+
|
7
|
+
module TestApp
|
8
|
+
class Application < Rails::Application
|
9
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
10
|
+
config.encoding = "utf-8"
|
11
|
+
|
12
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
13
|
+
config.filter_parameters += [:password]
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
development:
|
4
|
+
adapter: sqlite3
|
5
|
+
database: db/development.sqlite3
|
6
|
+
pool: 5
|
7
|
+
timeout: 5000
|
8
|
+
|
9
|
+
# Warning: The database defined as "test" will be erased and
|
10
|
+
# re-generated from your development database when you run "rake".
|
11
|
+
# Do not set this db to the same as development or production.
|
12
|
+
test:
|
13
|
+
adapter: sqlite3
|
14
|
+
database: db/test.sqlite3
|
15
|
+
pool: 5
|
16
|
+
timeout: 5000
|
17
|
+
|
18
|
+
production:
|
19
|
+
adapter: sqlite3
|
20
|
+
database: db/production.sqlite3
|
21
|
+
pool: 5
|
22
|
+
timeout: 5000
|
@@ -0,0 +1,26 @@
|
|
1
|
+
TestApp::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
7
|
+
config.cache_classes = false
|
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.consider_all_requests_local = true
|
14
|
+
config.action_view.debug_rjs = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Don't care if the mailer can't send
|
18
|
+
config.action_mailer.raise_delivery_errors = false
|
19
|
+
|
20
|
+
# Print deprecation notices to the Rails logger
|
21
|
+
config.active_support.deprecation = :log
|
22
|
+
|
23
|
+
# Only use best-standards-support built into browsers
|
24
|
+
config.action_dispatch.best_standards_support = :builtin
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
TestApp::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The production environment is meant for finished, "live" apps.
|
5
|
+
# Code is not reloaded between requests
|
6
|
+
config.cache_classes = true
|
7
|
+
|
8
|
+
# Full error reports are disabled and caching is turned on
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_controller.perform_caching = true
|
11
|
+
|
12
|
+
# Specifies the header that your server uses for sending files
|
13
|
+
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
14
|
+
|
15
|
+
# For nginx:
|
16
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
17
|
+
|
18
|
+
# If you have no front-end server that supports something like X-Sendfile,
|
19
|
+
# just comment this out and Rails will serve the files
|
20
|
+
|
21
|
+
# See everything in the log (default is :info)
|
22
|
+
# config.log_level = :debug
|
23
|
+
|
24
|
+
# Use a different logger for distributed setups
|
25
|
+
# config.logger = SyslogLogger.new
|
26
|
+
|
27
|
+
# Use a different cache store in production
|
28
|
+
# config.cache_store = :mem_cache_store
|
29
|
+
|
30
|
+
# Disable Rails's static asset server
|
31
|
+
# In production, Apache or nginx will already do this
|
32
|
+
config.serve_static_assets = false
|
33
|
+
|
34
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
35
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
36
|
+
|
37
|
+
# Disable delivery errors, bad email addresses will be ignored
|
38
|
+
# config.action_mailer.raise_delivery_errors = false
|
39
|
+
|
40
|
+
# Enable threaded mode
|
41
|
+
# config.threadsafe!
|
42
|
+
|
43
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
44
|
+
# the I18n.default_locale when a translation can not be found)
|
45
|
+
config.i18n.fallbacks = true
|
46
|
+
|
47
|
+
# Send deprecation notices to registered listeners
|
48
|
+
config.active_support.deprecation = :notify
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
TestApp::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Log error messages when you accidentally call methods on nil.
|
11
|
+
config.whiny_nils = true
|
12
|
+
|
13
|
+
# Show full error reports and disable caching
|
14
|
+
config.consider_all_requests_local = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Raise exceptions instead of rendering exception templates
|
18
|
+
config.action_dispatch.show_exceptions = false
|
19
|
+
|
20
|
+
# Disable request forgery protection in test environment
|
21
|
+
config.action_controller.allow_forgery_protection = false
|
22
|
+
|
23
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
24
|
+
# The :test delivery method accumulates sent emails in the
|
25
|
+
# ActionMailer::Base.deliveries array.
|
26
|
+
config.action_mailer.delivery_method = :test
|
27
|
+
|
28
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
29
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
30
|
+
# like if you have constraints or database-specific column types
|
31
|
+
# config.active_record.schema_format = :sql
|
32
|
+
|
33
|
+
# Print deprecation notices to the stderr
|
34
|
+
config.active_support.deprecation = :stderr
|
35
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
TestApp::Application.config.secret_token = 'c362f09b453ec024bd3095ac4dcaa4e2e4205195349962f8ce03094a7644679625ea123c322123a33da3a6bd040998a7df03efcf3073bbc179b2c3ab2f542cc4'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
TestApp::Application.config.session_store :cookie_store, :key => '_test_app_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# TestApp::Application.config.session_store :active_record_store
|
Binary file
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your
|
6
|
+
# database schema. If you need to create the application database on another
|
7
|
+
# system, you should be using db:schema:load, not running all the migrations
|
8
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
9
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
10
|
+
#
|
11
|
+
# It's strongly recommended to check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(:version => 1) do
|
14
|
+
|
15
|
+
create_table "contacts", :force => true do |t|
|
16
|
+
t.string "name"
|
17
|
+
t.string "website"
|
18
|
+
t.integer "age"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
|
7
|
+
# Mayor.create(:name => 'Daley', :city => cities.first)
|
Binary file
|