extjs_renderer 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +112 -0
- data/MIT-LICENSE +20 -0
- data/README.md +63 -0
- data/Rakefile +25 -0
- data/extjs_renderer.gemspec +26 -0
- data/lib/extjs_renderer/renderer.rb +31 -0
- data/lib/extjs_renderer/version.rb +3 -0
- data/lib/extjs_renderer.rb +2 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/items_controller.rb +17 -0
- data/spec/dummy/app/controllers/orders_controller.rb +115 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/helpers/orders_helper.rb +2 -0
- data/spec/dummy/app/models/item.rb +8 -0
- data/spec/dummy/app/models/order.rb +10 -0
- data/spec/dummy/app/views/items/index.html.erb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/orders/index.html.erb +2 -0
- data/spec/dummy/config/application.rb +48 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/json.rb +1 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +79 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20111116202653_create_orders.rb +13 -0
- data/spec/dummy/db/migrate/20111116202739_create_items.rb +14 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +191 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/spec/controllers/items_controller_spec.rb +42 -0
- data/spec/dummy/spec/controllers/orders_controller_spec.rb +216 -0
- data/spec/dummy/spec/models/order_spec.rb +24 -0
- data/spec/extjs_renderer_spec.rb +7 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/factories.rb +14 -0
- metadata +199 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
extjs_renderer (0.1.3)
|
|
5
|
+
actionpack (> 3.0.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
abstract (1.0.0)
|
|
11
|
+
actionmailer (3.0.11)
|
|
12
|
+
actionpack (= 3.0.11)
|
|
13
|
+
mail (~> 2.2.19)
|
|
14
|
+
actionpack (3.0.11)
|
|
15
|
+
activemodel (= 3.0.11)
|
|
16
|
+
activesupport (= 3.0.11)
|
|
17
|
+
builder (~> 2.1.2)
|
|
18
|
+
erubis (~> 2.6.6)
|
|
19
|
+
i18n (~> 0.5.0)
|
|
20
|
+
rack (~> 1.2.1)
|
|
21
|
+
rack-mount (~> 0.6.14)
|
|
22
|
+
rack-test (~> 0.5.7)
|
|
23
|
+
tzinfo (~> 0.3.23)
|
|
24
|
+
activemodel (3.0.11)
|
|
25
|
+
activesupport (= 3.0.11)
|
|
26
|
+
builder (~> 2.1.2)
|
|
27
|
+
i18n (~> 0.5.0)
|
|
28
|
+
activerecord (3.0.11)
|
|
29
|
+
activemodel (= 3.0.11)
|
|
30
|
+
activesupport (= 3.0.11)
|
|
31
|
+
arel (~> 2.0.10)
|
|
32
|
+
tzinfo (~> 0.3.23)
|
|
33
|
+
activeresource (3.0.11)
|
|
34
|
+
activemodel (= 3.0.11)
|
|
35
|
+
activesupport (= 3.0.11)
|
|
36
|
+
activesupport (3.0.11)
|
|
37
|
+
arel (2.0.10)
|
|
38
|
+
builder (2.1.2)
|
|
39
|
+
diff-lcs (1.1.3)
|
|
40
|
+
erubis (2.6.6)
|
|
41
|
+
abstract (>= 1.0.0)
|
|
42
|
+
factory_girl (2.3.0)
|
|
43
|
+
activesupport
|
|
44
|
+
factory_girl_rails (1.4.0)
|
|
45
|
+
factory_girl (~> 2.3.0)
|
|
46
|
+
railties (>= 3.0.0)
|
|
47
|
+
i18n (0.5.0)
|
|
48
|
+
json (1.6.1)
|
|
49
|
+
kaminari (0.12.4)
|
|
50
|
+
rails (>= 3.0.0)
|
|
51
|
+
mail (2.2.19)
|
|
52
|
+
activesupport (>= 2.3.6)
|
|
53
|
+
i18n (>= 0.4.0)
|
|
54
|
+
mime-types (~> 1.16)
|
|
55
|
+
treetop (~> 1.4.8)
|
|
56
|
+
mime-types (1.17.2)
|
|
57
|
+
polyglot (0.3.3)
|
|
58
|
+
rack (1.2.4)
|
|
59
|
+
rack-mount (0.6.14)
|
|
60
|
+
rack (>= 1.0.0)
|
|
61
|
+
rack-test (0.5.7)
|
|
62
|
+
rack (>= 1.0)
|
|
63
|
+
rails (3.0.11)
|
|
64
|
+
actionmailer (= 3.0.11)
|
|
65
|
+
actionpack (= 3.0.11)
|
|
66
|
+
activerecord (= 3.0.11)
|
|
67
|
+
activeresource (= 3.0.11)
|
|
68
|
+
activesupport (= 3.0.11)
|
|
69
|
+
bundler (~> 1.0)
|
|
70
|
+
railties (= 3.0.11)
|
|
71
|
+
railties (3.0.11)
|
|
72
|
+
actionpack (= 3.0.11)
|
|
73
|
+
activesupport (= 3.0.11)
|
|
74
|
+
rake (>= 0.8.7)
|
|
75
|
+
rdoc (~> 3.4)
|
|
76
|
+
thor (~> 0.14.4)
|
|
77
|
+
rake (0.9.2.2)
|
|
78
|
+
rdoc (3.11)
|
|
79
|
+
json (~> 1.4)
|
|
80
|
+
rspec (2.7.0)
|
|
81
|
+
rspec-core (~> 2.7.0)
|
|
82
|
+
rspec-expectations (~> 2.7.0)
|
|
83
|
+
rspec-mocks (~> 2.7.0)
|
|
84
|
+
rspec-core (2.7.1)
|
|
85
|
+
rspec-expectations (2.7.0)
|
|
86
|
+
diff-lcs (~> 1.1.2)
|
|
87
|
+
rspec-mocks (2.7.0)
|
|
88
|
+
rspec-rails (2.7.0)
|
|
89
|
+
actionpack (~> 3.0)
|
|
90
|
+
activesupport (~> 3.0)
|
|
91
|
+
railties (~> 3.0)
|
|
92
|
+
rspec (~> 2.7.0)
|
|
93
|
+
sqlite3 (1.3.4)
|
|
94
|
+
thor (0.14.6)
|
|
95
|
+
treetop (1.4.10)
|
|
96
|
+
polyglot
|
|
97
|
+
polyglot (>= 0.3.1)
|
|
98
|
+
tzinfo (0.3.31)
|
|
99
|
+
will_paginate (3.0.2)
|
|
100
|
+
|
|
101
|
+
PLATFORMS
|
|
102
|
+
ruby
|
|
103
|
+
|
|
104
|
+
DEPENDENCIES
|
|
105
|
+
extjs_renderer!
|
|
106
|
+
factory_girl_rails
|
|
107
|
+
kaminari
|
|
108
|
+
rails (~> 3.0.0)
|
|
109
|
+
rspec (~> 2.7.0)
|
|
110
|
+
rspec-rails (~> 2.7.0)
|
|
111
|
+
sqlite3
|
|
112
|
+
will_paginate (~> 3.0.0)
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2011 Mark H Winkler
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# ExtjsRenderer
|
|
2
|
+
|
|
3
|
+
Rails 3 Renderer to send JSON compatible with Sencha Extjs 3+
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
### ActiveRecord Relations
|
|
8
|
+
|
|
9
|
+
JSON root defaults to resource:
|
|
10
|
+
|
|
11
|
+
Controller action:
|
|
12
|
+
|
|
13
|
+
def index
|
|
14
|
+
@items = Item.order('name')
|
|
15
|
+
respond_with @items do |format|
|
|
16
|
+
format.json { render :extjs => @items }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
Output:
|
|
21
|
+
|
|
22
|
+
{"total":1,"item":[{"id":1,"name":"widget"}]}
|
|
23
|
+
|
|
24
|
+
Custom JSON root and to_json params:
|
|
25
|
+
|
|
26
|
+
Controller action:
|
|
27
|
+
|
|
28
|
+
def index
|
|
29
|
+
@items = Item.order('name')
|
|
30
|
+
respond_with @items do |format|
|
|
31
|
+
format.json { render :extjs => @items, :root => "product", :only => [:name], :methods => [:custom] }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
Or
|
|
36
|
+
|
|
37
|
+
def index
|
|
38
|
+
@items = Item.order('name')
|
|
39
|
+
respond_with @items do |format|
|
|
40
|
+
format.json { render :extjs => @items, :root => "product", :except => [:id], :methods => [:custom] }
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
Output:
|
|
45
|
+
|
|
46
|
+
{"total":1,"product":[{"name":"widget","custom":"custom method output"}]}
|
|
47
|
+
|
|
48
|
+
### Single Resource
|
|
49
|
+
|
|
50
|
+
Root defaults to 'data' or :root => 'custom':
|
|
51
|
+
|
|
52
|
+
Controller action:
|
|
53
|
+
|
|
54
|
+
def edit
|
|
55
|
+
@item = Item.find(params[:id])
|
|
56
|
+
respond_with @items do |format|
|
|
57
|
+
format.json { render :extjs => @item, :only => [:name], :methods => [:custom] }
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
Output:
|
|
62
|
+
|
|
63
|
+
{"success":true,"data":[{"name":"widget","custom":"custom method output"}]}
|
data/Rakefile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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 'rspec/core'
|
|
13
|
+
require 'rspec/core/rake_task'
|
|
14
|
+
|
|
15
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
16
|
+
|
|
17
|
+
task :default => :spec
|
|
18
|
+
|
|
19
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
20
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
21
|
+
rdoc.title = 'ExtjsRenderer'
|
|
22
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
|
23
|
+
rdoc.rdoc_files.include('README.md')
|
|
24
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
25
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "extjs_renderer/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "extjs_renderer"
|
|
7
|
+
s.version = ExtjsRenderer::VERSION
|
|
8
|
+
s.authors = ["Mark H Winkler"]
|
|
9
|
+
s.email = ["mhwinkler@gmail.com"]
|
|
10
|
+
s.homepage = "https://github.com/mojomaze/extjs_renderer"
|
|
11
|
+
s.summary = "Rails 3 Renderer for ExtJ3+"
|
|
12
|
+
s.description = "Rails 3 Renderer for JSON compatible with Sencha Extjs 3+"
|
|
13
|
+
|
|
14
|
+
s.files = `git ls-files`.split("\n")
|
|
15
|
+
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
|
16
|
+
s.require_paths = ["lib"]
|
|
17
|
+
|
|
18
|
+
s.add_development_dependency "rails", "~> 3.0.0"
|
|
19
|
+
s.add_development_dependency "sqlite3"
|
|
20
|
+
s.add_development_dependency "rspec", "~> 2.7.0"
|
|
21
|
+
s.add_development_dependency "rspec-rails", "~> 2.7.0"
|
|
22
|
+
s.add_development_dependency "factory_girl_rails"
|
|
23
|
+
s.add_development_dependency "will_paginate", "~> 3.0.0"
|
|
24
|
+
s.add_development_dependency "kaminari"
|
|
25
|
+
s.add_runtime_dependency "actionpack", "> 3.0.0"
|
|
26
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module ExtjsRenderer
|
|
2
|
+
require "action_controller"
|
|
3
|
+
|
|
4
|
+
ActionController::Renderers.add :extjs do |resource, options|
|
|
5
|
+
if resource.is_a?(ActiveRecord::Relation)
|
|
6
|
+
# get or set the total
|
|
7
|
+
if options && options.has_key?(:total)
|
|
8
|
+
total = options[:total] # set if passed
|
|
9
|
+
elsif resource.respond_to?(:total_count)
|
|
10
|
+
total = resource.total_count # kaminari total found
|
|
11
|
+
elsif resource.respond_to?(:total_entries)
|
|
12
|
+
total = resource.total_entries # will_paginate total found
|
|
13
|
+
else
|
|
14
|
+
total = resource.size # total in relation
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# set root to passed or resource
|
|
18
|
+
root = options && options.has_key?(:root) ? options[:root] : resource.last.class.name.downcase
|
|
19
|
+
|
|
20
|
+
json = '{"total":'+total.to_s+',"'+root+'":'+resource.to_json(options)+'}'
|
|
21
|
+
|
|
22
|
+
else
|
|
23
|
+
# set root to passed or 'data' which is used by extjs to load forms
|
|
24
|
+
root = options && options.has_key?(:root) ? options[:root] : 'data'
|
|
25
|
+
|
|
26
|
+
json = '{"success":true,"'+root+'":'+resource.to_json(options)+'}'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
send_data(json, :type => :json)
|
|
30
|
+
end
|
|
31
|
+
end
|
data/spec/dummy/Rakefile
ADDED
|
@@ -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
|
+
Dummy::Application.load_tasks
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class ItemsController < ApplicationController
|
|
2
|
+
respond_to :html, :json
|
|
3
|
+
|
|
4
|
+
def index
|
|
5
|
+
@items = Item.order('name')
|
|
6
|
+
respond_with @items do |format|
|
|
7
|
+
format.json { render :extjs => @items }
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def edit
|
|
12
|
+
@item = Item.find(params[:id])
|
|
13
|
+
respond_with @item do |format|
|
|
14
|
+
format.json { render :extjs => @item }
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
class OrdersController < ApplicationController
|
|
2
|
+
respond_to :html, :json
|
|
3
|
+
def index
|
|
4
|
+
@orders = Order.order('name')
|
|
5
|
+
respond_with @orders do |format|
|
|
6
|
+
format.json { render :extjs => @orders }
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def index_with_nested_resource
|
|
11
|
+
@orders = Order.order('name')
|
|
12
|
+
respond_with @orders do |format|
|
|
13
|
+
format.json { render :extjs => @orders, :include => :items }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def change_root
|
|
18
|
+
@orders = Order.order('name')
|
|
19
|
+
respond_with @orders do |format|
|
|
20
|
+
format.json { render :extjs => @orders, :root => 'custom_root' }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def change_total
|
|
25
|
+
@orders = Order.order('name')
|
|
26
|
+
respond_with @orders do |format|
|
|
27
|
+
format.json { render :extjs => @orders, :total => 34 }
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def with_method
|
|
32
|
+
@orders = Order.order('name')
|
|
33
|
+
respond_with @orders do |format|
|
|
34
|
+
format.json { render :extjs => @orders, :root => 'custom_root', :total => 34,
|
|
35
|
+
:methods => [:custom] }
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def only_and_method
|
|
40
|
+
@orders = Order.order('name')
|
|
41
|
+
respond_with @orders do |format|
|
|
42
|
+
format.json { render :extjs => @orders, :root => 'custom_root', :total => 34,
|
|
43
|
+
:only => :name, :methods => :custom }
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def except_and_method
|
|
48
|
+
@orders = Order.order('name')
|
|
49
|
+
respond_with @orders do |format|
|
|
50
|
+
format.json { render :extjs => @orders, :root => 'custom_root', :total => 34,
|
|
51
|
+
:except => [:created_at, :updated_at], :methods => :custom }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# pagination
|
|
56
|
+
def index_will_paginate
|
|
57
|
+
@orders = Order.where("name LIKE ?", '%order%').paginate(:page => 1, :per_page => 25)
|
|
58
|
+
respond_with @orders do |format|
|
|
59
|
+
format.json { render :extjs => @orders }
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def index_kaminari_pagination
|
|
64
|
+
@orders = Order.where("name LIKE ?", '%order%').page(1)
|
|
65
|
+
respond_with @orders do |format|
|
|
66
|
+
format.json { render :extjs => @orders }
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def edit
|
|
71
|
+
@order = Order.find(params[:id])
|
|
72
|
+
respond_with @order do |format|
|
|
73
|
+
format.json { render :extjs => @order }
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def edit_change_root
|
|
78
|
+
@order = Order.find(params[:id])
|
|
79
|
+
respond_with @order do |format|
|
|
80
|
+
format.json { render :extjs => @order, :root => 'custom_root' }
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def edit_with_method
|
|
85
|
+
@order = Order.find(params[:id])
|
|
86
|
+
respond_with @order do |format|
|
|
87
|
+
format.json { render :extjs => @order, :root => 'custom_root',
|
|
88
|
+
:methods => :custom }
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def edit_only_and_method
|
|
93
|
+
@order = Order.find(params[:id])
|
|
94
|
+
respond_with @order do |format|
|
|
95
|
+
format.json { render :extjs => @order, :root => 'custom_root',
|
|
96
|
+
:methods => :custom, :only => [:id, :name] }
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def edit_except_and_method
|
|
101
|
+
@order = Order.find(params[:id])
|
|
102
|
+
respond_with @order do |format|
|
|
103
|
+
format.json { render :extjs => @order, :root => 'custom_root',
|
|
104
|
+
:methods => :custom, :except => [:created_at, :updated_at] }
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def edit_with_nested_resource
|
|
109
|
+
@order = Order.find(params[:id])
|
|
110
|
+
respond_with @order do |format|
|
|
111
|
+
format.json { render :extjs => @order, :include => :items }
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
require "active_model/railtie"
|
|
4
|
+
require "active_record/railtie"
|
|
5
|
+
require "action_controller/railtie"
|
|
6
|
+
require "action_view/railtie"
|
|
7
|
+
require "action_mailer/railtie"
|
|
8
|
+
|
|
9
|
+
Bundler.require
|
|
10
|
+
|
|
11
|
+
#require "kaminari"
|
|
12
|
+
require "will_paginate"
|
|
13
|
+
require "extjs_renderer"
|
|
14
|
+
|
|
15
|
+
module Dummy
|
|
16
|
+
class Application < Rails::Application
|
|
17
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
18
|
+
# Application configuration should go into files in config/initializers
|
|
19
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
20
|
+
|
|
21
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
|
22
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
|
23
|
+
|
|
24
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
|
25
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
|
26
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
|
27
|
+
|
|
28
|
+
# Activate observers that should always be running.
|
|
29
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
|
30
|
+
|
|
31
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
32
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
33
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
|
34
|
+
|
|
35
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
36
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
37
|
+
# config.i18n.default_locale = :de
|
|
38
|
+
|
|
39
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
|
40
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
|
41
|
+
|
|
42
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
|
43
|
+
config.encoding = "utf-8"
|
|
44
|
+
|
|
45
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
|
46
|
+
config.filter_parameters += [:password]
|
|
47
|
+
end
|
|
48
|
+
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
|
+
Dummy::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
|
+
Dummy::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
|