railties 3.1.0.rc5 → 3.1.0.rc6
Sign up to get free protection for your applications and to get access to all the features.
- data/guides/rails_guides/generator.rb +4 -44
- data/guides/rails_guides/textile_extensions.rb +22 -3
- data/guides/source/3_1_release_notes.textile +429 -0
- data/guides/source/action_mailer_basics.textile +4 -2
- data/guides/source/active_record_validations_callbacks.textile +56 -13
- data/guides/source/active_resource_basics.textile +74 -0
- data/guides/source/active_support_core_extensions.textile +36 -0
- data/guides/source/asset_pipeline.textile +59 -60
- data/guides/source/command_line.textile +3 -1
- data/guides/source/configuring.textile +1 -1
- data/guides/source/getting_started.textile +11 -15
- data/guides/source/i18n.textile +1 -1
- data/guides/source/initialization.textile +4 -3
- data/guides/source/layouts_and_rendering.textile +2 -2
- data/guides/source/migrations.textile +23 -23
- data/guides/source/rails_application_templates.textile +1 -7
- data/lib/rails/application.rb +1 -3
- data/lib/rails/application/configuration.rb +1 -0
- data/lib/rails/engine.rb +3 -3
- data/lib/rails/generators/app_base.rb +12 -0
- data/lib/rails/generators/rails/app/templates/Gemfile +1 -8
- data/lib/rails/generators/rails/app/templates/config/application.rb +6 -4
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +7 -3
- data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +2 -2
- data/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +22 -7
- data/lib/rails/generators/rails/plugin_new/templates/Gemfile +13 -7
- data/lib/rails/generators/rails/plugin_new/templates/app/mailers/.empty_directory +0 -0
- data/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/{application.html.erb.tt → %name%/application.html.erb.tt} +0 -0
- data/lib/rails/generators/rails/plugin_new/templates/lib/%name%/version.rb +3 -0
- data/lib/rails/paths.rb +4 -0
- data/lib/rails/railtie.rb +1 -0
- data/lib/rails/tasks/misc.rake +1 -1
- data/lib/rails/version.rb +1 -1
- metadata +34 -12
@@ -386,9 +386,11 @@ Action Pack version 3.1.0
|
|
386
386
|
Active Resource version 3.1.0
|
387
387
|
Action Mailer version 3.1.0
|
388
388
|
Active Support version 3.1.0
|
389
|
-
Middleware ActionDispatch::Static, Rack::Lock, Rack::Runtime, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::RemoteIp,
|
389
|
+
Middleware ActionDispatch::Static, Rack::Lock, Rack::Runtime, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::RemoteIp, ActionDispatch::Callbacks, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::MethodOverride, ActionDispatch::Head
|
390
390
|
Application root /home/foobar/commandsapp
|
391
391
|
Environment development
|
392
|
+
Database adapter sqlite3
|
393
|
+
Database schema version 0
|
392
394
|
</shell>
|
393
395
|
|
394
396
|
h4. +assets+
|
@@ -557,7 +557,7 @@ The error occurred while evaluating nil.each
|
|
557
557
|
|
558
558
|
*+set_load_path+* This initializer runs before +bootstrap_hook+. Adds the +vendor+, +lib+, all directories of +app+ and any paths specified by +config.load_paths+ to +$LOAD_PATH+.
|
559
559
|
|
560
|
-
*+
|
560
|
+
*+set_autoload_paths+* This initializer runs before +bootstrap_hook+. Adds all sub-directories of +app+ and paths specified by +config.autoload_paths+ to +ActiveSupport::Dependencies.autoload_paths+.
|
561
561
|
|
562
562
|
*+add_routing_paths+* Loads (by default) all +config/routes.rb+ files (in the application and railties, including engines) and sets up the routes for the application.
|
563
563
|
|
@@ -536,21 +536,8 @@ command in your terminal:
|
|
536
536
|
$ rails generate scaffold Post name:string title:string content:text
|
537
537
|
</shell>
|
538
538
|
|
539
|
-
|
540
|
-
|
541
|
-
(type text). It will also hook this new database up to Rails (details below).
|
542
|
-
|
543
|
-
NOTE. While scaffolding will get you up and running quickly, the code it
|
544
|
-
generates is unlikely to be a perfect fit for your application. You'll most
|
545
|
-
probably want to customize the generated code. Many experienced Rails developers
|
546
|
-
avoid scaffolding entirely, preferring to write all or most of their source code
|
547
|
-
from scratch. Rails, however, makes it really simple to customize templates for
|
548
|
-
generated models, controllers, views and other source files. You'll find more
|
549
|
-
information in the "Creating and Customizing Rails Generators &
|
550
|
-
Templates":generators.html guide.
|
551
|
-
|
552
|
-
The scaffold generator will build 17 files in your application, along with some
|
553
|
-
folders, and edit one more. Here's a quick overview of what it creates:
|
539
|
+
The scaffold generator will build several files in your application, along with some
|
540
|
+
folders, and edit <tt>config/routes.rb</tt>. Here's a quick overview of what it creates:
|
554
541
|
|
555
542
|
|_.File |_.Purpose|
|
556
543
|
|db/migrate/20100207214725_create_posts.rb |Migration to create the posts table in your database (your name will include a different timestamp)|
|
@@ -571,6 +558,15 @@ folders, and edit one more. Here's a quick overview of what it creates:
|
|
571
558
|
|test/unit/helpers/posts_helper_test.rb |Unit testing harness for the posts helper|
|
572
559
|
|config/routes.rb |Edited to include routing information for posts|
|
573
560
|
|
561
|
+
NOTE. While scaffolding will get you up and running quickly, the code it
|
562
|
+
generates is unlikely to be a perfect fit for your application. You'll most
|
563
|
+
probably want to customize the generated code. Many experienced Rails developers
|
564
|
+
avoid scaffolding entirely, preferring to write all or most of their source code
|
565
|
+
from scratch. Rails, however, makes it really simple to customize templates for
|
566
|
+
generated models, controllers, views and other source files. You'll find more
|
567
|
+
information in the "Creating and Customizing Rails Generators &
|
568
|
+
Templates":generators.html guide.
|
569
|
+
|
574
570
|
h4. Running a Migration
|
575
571
|
|
576
572
|
One of the products of the +rails generate scaffold+ command is a _database
|
data/guides/source/i18n.textile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
h2. Rails Internationalization (I18n) API
|
2
2
|
|
3
3
|
The Ruby I18n (shorthand for _internationalization_) gem which is shipped with Ruby on Rails (starting from Rails 2.2) provides an easy-to-use and extensible framework for *translating your application to a single custom language* other than English or for *providing multi-language support* in your application.
|
4
4
|
|
@@ -33,7 +33,7 @@ end
|
|
33
33
|
|
34
34
|
This file will attempt to load +rails/cli+ and if it cannot find it then add the +railties/lib+ path to the load path (+$:+) and will then try to require it again.
|
35
35
|
|
36
|
-
h4. +
|
36
|
+
h4. +railties/lib/rails/cli.rb+
|
37
37
|
|
38
38
|
This file looks like this:
|
39
39
|
|
@@ -71,7 +71,7 @@ module Rails
|
|
71
71
|
end
|
72
72
|
</ruby>
|
73
73
|
|
74
|
-
The +rails/script_rails_loader+ file uses +RbConfig::Config+ to gather up the +bin_dir+ and +ruby_install_name+ values for the configuration which will result in a path such as +/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby+, which is the default path on Mac OS X. If you're running Windows the path may be something such as +C:/Ruby192/bin/ruby+. Anyway, the path on your system may be different, but the point of this is that it will point at the known ruby executable location for your install. The +RbConfig::CONFIG["EXEEXT"]+ will suffix this path with ".exe" if the script is running on Windows. This constant is used later on in +exec_script_rails!+. As for the +SCRIPT_RAILS+
|
74
|
+
The +rails/script_rails_loader+ file uses +RbConfig::Config+ to gather up the +bin_dir+ and +ruby_install_name+ values for the configuration which will result in a path such as +/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby+, which is the default path on Mac OS X. If you're running Windows the path may be something such as +C:/Ruby192/bin/ruby+. Anyway, the path on your system may be different, but the point of this is that it will point at the known ruby executable location for your install. The +RbConfig::CONFIG["EXEEXT"]+ will suffix this path with ".exe" if the script is running on Windows. This constant is used later on in +exec_script_rails!+. As for the +SCRIPT_RAILS+ constant, we'll see that when we get to the +in_rails_application?+ method.
|
75
75
|
|
76
76
|
Back in +rails/cli+, the next line is this:
|
77
77
|
|
@@ -190,7 +190,8 @@ aliases = {
|
|
190
190
|
"g" => "generate",
|
191
191
|
"c" => "console",
|
192
192
|
"s" => "server",
|
193
|
-
"db" => "dbconsole"
|
193
|
+
"db" => "dbconsole",
|
194
|
+
"r" => "runner"
|
194
195
|
}
|
195
196
|
|
196
197
|
command = ARGV.shift
|
@@ -1179,14 +1179,14 @@ On pages generated by +NewsController+, you want to hide the top menu and add a
|
|
1179
1179
|
<% end %>
|
1180
1180
|
<% content_for :content do %>
|
1181
1181
|
<div id="right_menu">Right menu items here</div>
|
1182
|
-
<%= yield(:news_content)
|
1182
|
+
<%= content_for?(:news_content) ? yield(:news_content) : yield %>
|
1183
1183
|
<% end %>
|
1184
1184
|
<%= render :template => 'layouts/application' %>
|
1185
1185
|
</erb>
|
1186
1186
|
|
1187
1187
|
That's it. The News views will use the new layout, hiding the top menu and adding a new right menu inside the "content" div.
|
1188
1188
|
|
1189
|
-
There are several ways of getting similar results with different sub-templating schemes using this technique. Note that there is no limit in nesting levels. One can use the +ActionView::render+ method via +render :template => 'layouts/news'+ to base a new layout on the News layout. If you are sure you will not subtemplate the +News+ layout, you can replace the +yield(:news_content)
|
1189
|
+
There are several ways of getting similar results with different sub-templating schemes using this technique. Note that there is no limit in nesting levels. One can use the +ActionView::render+ method via +render :template => 'layouts/news'+ to base a new layout on the News layout. If you are sure you will not subtemplate the +News+ layout, you can replace the +content_for?(:news_content) ? yield(:news_content) : yield+ with simply +yield+.
|
1190
1190
|
|
1191
1191
|
h3. Changelog
|
1192
1192
|
|
@@ -471,13 +471,13 @@ By default migrations tell you exactly what they're doing and how long it took.
|
|
471
471
|
|
472
472
|
Several methods are provided that allow you to control all this:
|
473
473
|
|
474
|
-
* +suppress_messages+ suppresses any output generated by
|
475
|
-
* +say+ outputs
|
474
|
+
* +suppress_messages+ takes a block as an argument and suppresses any output generated by the block.
|
475
|
+
* +say+ takes a message argument and outputs it as is. A second boolean argument can be passed to specify whether to indent or not.
|
476
476
|
* +say_with_time+ outputs text along with how long it took to run its block. If the block returns an integer it assumes it is the number of rows affected.
|
477
477
|
|
478
478
|
For example, this migration
|
479
479
|
|
480
|
-
<
|
480
|
+
<ruby>
|
481
481
|
class CreateProducts < ActiveRecord::Migration
|
482
482
|
def change
|
483
483
|
suppress_messages do
|
@@ -496,7 +496,7 @@ class CreateProducts < ActiveRecord::Migration
|
|
496
496
|
end
|
497
497
|
end
|
498
498
|
end
|
499
|
-
</
|
499
|
+
</ruby>
|
500
500
|
|
501
501
|
generates the following output
|
502
502
|
|
@@ -510,7 +510,7 @@ generates the following output
|
|
510
510
|
20080906170109 CreateProducts: migrated (10.0097s)
|
511
511
|
</shell>
|
512
512
|
|
513
|
-
If you just want Active Record to shut up then running +rake db:migrate VERBOSE=false+ will suppress
|
513
|
+
If you just want Active Record to shut up then running +rake db:migrate VERBOSE=false+ will suppress all output.
|
514
514
|
|
515
515
|
h3. Using Models in Your Migrations
|
516
516
|
|
@@ -525,7 +525,7 @@ Bob goes on vacation.
|
|
525
525
|
Alice creates a migration for the +products+ table which adds a new column and initializes it.
|
526
526
|
She also adds a validation to the Product model for the new column.
|
527
527
|
|
528
|
-
<
|
528
|
+
<ruby>
|
529
529
|
# db/migrate/20100513121110_add_flag_to_product.rb
|
530
530
|
|
531
531
|
class AddFlagToProduct < ActiveRecord::Migration
|
@@ -534,19 +534,19 @@ class AddFlagToProduct < ActiveRecord::Migration
|
|
534
534
|
Product.all.each { |f| f.update_attributes!(:flag => 'false') }
|
535
535
|
end
|
536
536
|
end
|
537
|
-
</
|
537
|
+
</ruby>
|
538
538
|
|
539
|
-
<
|
539
|
+
<ruby>
|
540
540
|
# app/model/product.rb
|
541
541
|
|
542
542
|
class Product < ActiveRecord::Base
|
543
|
-
|
543
|
+
validates :flag, :presence => true
|
544
544
|
end
|
545
|
-
</
|
545
|
+
</ruby>
|
546
546
|
|
547
547
|
Alice adds a second migration which adds and initializes another column to the +products+ table and also adds a validation to the Product model for the new column.
|
548
548
|
|
549
|
-
<
|
549
|
+
<ruby>
|
550
550
|
# db/migrate/20100515121110_add_fuzz_to_product.rb
|
551
551
|
|
552
552
|
class AddFuzzToProduct < ActiveRecord::Migration
|
@@ -555,16 +555,15 @@ class AddFuzzToProduct < ActiveRecord::Migration
|
|
555
555
|
Product.all.each { |f| f.update_attributes! :fuzz => 'fuzzy' }
|
556
556
|
end
|
557
557
|
end
|
558
|
-
</
|
558
|
+
</ruby>
|
559
559
|
|
560
|
-
<
|
560
|
+
<ruby>
|
561
561
|
# app/model/product.rb
|
562
562
|
|
563
563
|
class Product < ActiveRecord::Base
|
564
|
-
|
565
|
-
validates_presence_of :fuzz
|
564
|
+
validates :flag, :fuzz, :presence => true
|
566
565
|
end
|
567
|
-
</
|
566
|
+
</ruby>
|
568
567
|
|
569
568
|
Both migrations work for Alice.
|
570
569
|
|
@@ -575,12 +574,12 @@ Bob comes back from vacation and:
|
|
575
574
|
|
576
575
|
The migration crashes because when the model attempts to save, it tries to validate the second added column, which is not in the database when the _first_ migration runs.
|
577
576
|
|
578
|
-
<
|
577
|
+
<plain>
|
579
578
|
rake aborted!
|
580
579
|
An error has occurred, this and all later migrations canceled:
|
581
580
|
|
582
581
|
undefined method `fuzz' for #<Product:0x000001049b14a0>
|
583
|
-
</
|
582
|
+
</plain>
|
584
583
|
|
585
584
|
A fix for this is to create a local model within the migration. This keeps rails from running the validations, so that the migrations run to completion.
|
586
585
|
|
@@ -588,21 +587,22 @@ When using a faux model, it's a good idea to call +Product.reset_column_informat
|
|
588
587
|
|
589
588
|
If Alice had done this instead, there would have been no problem:
|
590
589
|
|
591
|
-
<
|
590
|
+
<ruby>
|
592
591
|
# db/migrate/20100513121110_add_flag_to_product.rb
|
593
592
|
|
594
593
|
class AddFlagToProduct < ActiveRecord::Migration
|
595
594
|
class Product < ActiveRecord::Base
|
596
595
|
end
|
596
|
+
|
597
597
|
def change
|
598
598
|
add_column :products, :flag, :int
|
599
|
-
Product.reset_column_information
|
599
|
+
Product.reset_column_information
|
600
600
|
Product.all.each { |f| f.update_attributes!(:flag => false) }
|
601
601
|
end
|
602
602
|
end
|
603
|
-
</
|
603
|
+
</ruby>
|
604
604
|
|
605
|
-
<
|
605
|
+
<ruby>
|
606
606
|
# db/migrate/20100515121110_add_fuzz_to_product.rb
|
607
607
|
|
608
608
|
class AddFuzzToProduct < ActiveRecord::Migration
|
@@ -614,7 +614,7 @@ class AddFuzzToProduct < ActiveRecord::Migration
|
|
614
614
|
Product.all.each { |f| f.update_attributes! :fuzz => 'fuzzy' }
|
615
615
|
end
|
616
616
|
end
|
617
|
-
</
|
617
|
+
</ruby>
|
618
618
|
|
619
619
|
|
620
620
|
h3. Schema Dumping and You
|
@@ -148,7 +148,7 @@ The above creates +lib/tasks/bootstrap.rake+ with a +boot:strap+ rake task.
|
|
148
148
|
|
149
149
|
h4. generate(what, args)
|
150
150
|
|
151
|
-
Runs the supplied rails generator with given arguments.
|
151
|
+
Runs the supplied rails generator with given arguments.
|
152
152
|
|
153
153
|
<ruby>
|
154
154
|
generate(:scaffold, "person", "name:string", "address:text", "age:number")
|
@@ -176,12 +176,6 @@ You can also run rake tasks with a different Rails environment:
|
|
176
176
|
rake "db:migrate", :env => 'production'
|
177
177
|
</ruby>
|
178
178
|
|
179
|
-
Or even use sudo:
|
180
|
-
|
181
|
-
<ruby>
|
182
|
-
rake "gems:install", :sudo => true
|
183
|
-
</ruby>
|
184
|
-
|
185
179
|
h4. route(routing_code)
|
186
180
|
|
187
181
|
This adds a routing entry to the +config/routes.rb+ file. In above steps, we generated a person scaffold and also removed +public/index.html+. Now to make +PeopleController#index+ as the default page for the application:
|
data/lib/rails/application.rb
CHANGED
@@ -160,9 +160,7 @@ module Rails
|
|
160
160
|
middleware.use ::Rails::Rack::Logger # must come after Rack::MethodOverride to properly log overridden methods
|
161
161
|
middleware.use ::ActionDispatch::ShowExceptions, config.consider_all_requests_local
|
162
162
|
middleware.use ::ActionDispatch::RemoteIp, config.action_dispatch.ip_spoofing_check, config.action_dispatch.trusted_proxies
|
163
|
-
|
164
|
-
middleware.use ::Rack::Sendfile, config.action_dispatch.x_sendfile_header
|
165
|
-
end
|
163
|
+
middleware.use ::Rack::Sendfile, config.action_dispatch.x_sendfile_header
|
166
164
|
middleware.use ::ActionDispatch::Reloader unless config.cache_classes
|
167
165
|
middleware.use ::ActionDispatch::Callbacks
|
168
166
|
middleware.use ::ActionDispatch::Cookies
|
@@ -37,6 +37,7 @@ module Rails
|
|
37
37
|
@assets.paths = []
|
38
38
|
@assets.precompile = [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]
|
39
39
|
@assets.prefix = "/assets"
|
40
|
+
@assets.version = ''
|
40
41
|
|
41
42
|
@assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ]
|
42
43
|
@assets.js_compressor = nil
|
data/lib/rails/engine.rb
CHANGED
@@ -539,9 +539,9 @@ module Rails
|
|
539
539
|
end
|
540
540
|
|
541
541
|
initializer :append_assets_path do |app|
|
542
|
-
app.config.assets.paths.unshift(*paths["vendor/assets"].
|
543
|
-
app.config.assets.paths.unshift(*paths["lib/assets"].
|
544
|
-
app.config.assets.paths.unshift(*paths["app/assets"].
|
542
|
+
app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
|
543
|
+
app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
|
544
|
+
app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
|
545
545
|
end
|
546
546
|
|
547
547
|
initializer :prepend_helpers_path do |app|
|
@@ -202,6 +202,18 @@ module Rails
|
|
202
202
|
"gem '#{options[:javascript]}-rails'" unless options[:skip_javascript]
|
203
203
|
end
|
204
204
|
|
205
|
+
def assets_gemfile_entry
|
206
|
+
<<-GEMFILE.strip_heredoc
|
207
|
+
# Gems used only for assets and not required
|
208
|
+
# in production environments by default.
|
209
|
+
group :assets do
|
210
|
+
gem 'sass-rails', #{options.dev? || options.edge? ? " :git => 'git://github.com/rails/sass-rails.git', :branch => '3-1-stable'" : " ~> 3.1.0.rc".inspect}
|
211
|
+
gem 'coffee-rails', #{options.dev? || options.edge? ? ":git => 'git://github.com/rails/coffee-rails.git', :branch => '3-1-stable'" : "~> 3.1.0.rc".inspect}
|
212
|
+
gem 'uglifier'
|
213
|
+
end
|
214
|
+
GEMFILE
|
215
|
+
end
|
216
|
+
|
205
217
|
def bundle_command(command)
|
206
218
|
say_status :run, "bundle #{command}"
|
207
219
|
|
@@ -7,14 +7,7 @@ source 'http://rubygems.org'
|
|
7
7
|
<%= "gem 'jruby-openssl'\n" if defined?(JRUBY_VERSION) -%>
|
8
8
|
<%= "gem 'json'\n" if RUBY_VERSION < "1.9.2" -%>
|
9
9
|
|
10
|
-
|
11
|
-
# in production environments by default.
|
12
|
-
group :assets do
|
13
|
-
gem 'sass-rails', "~> 3.1.0.rc"
|
14
|
-
gem 'coffee-rails', "~> 3.1.0.rc"
|
15
|
-
gem 'uglifier'
|
16
|
-
end
|
17
|
-
|
10
|
+
<%= assets_gemfile_entry %>
|
18
11
|
<%= javascript_gemfile_entry %>
|
19
12
|
|
20
13
|
# Use unicorn as the web server
|
@@ -12,10 +12,12 @@ require "active_resource/railtie"
|
|
12
12
|
<%= comment_if :skip_test_unit %> require "rails/test_unit/railtie"
|
13
13
|
<% end -%>
|
14
14
|
|
15
|
-
|
16
|
-
#
|
17
|
-
|
18
|
-
|
15
|
+
if defined?(Bundler)
|
16
|
+
# If you precompile assets before deploying to production, use this line
|
17
|
+
Bundler.require *Rails.groups(:assets => %w(development test))
|
18
|
+
# If you want your assets lazily compiled in production, use this line
|
19
|
+
# Bundler.require(:default, :assets, Rails.env)
|
20
|
+
end
|
19
21
|
|
20
22
|
module <%= app_const_base %>
|
21
23
|
class Application < Rails::Application
|
@@ -15,8 +15,8 @@
|
|
15
15
|
config.assets.compress = true
|
16
16
|
|
17
17
|
# Specifies the header that your server uses for sending files
|
18
|
-
#
|
19
|
-
config.action_dispatch.x_sendfile_header =
|
18
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
19
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
20
20
|
|
21
21
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
22
22
|
# config.force_ssl = true
|
@@ -4,9 +4,13 @@
|
|
4
4
|
# is enabled by default.
|
5
5
|
|
6
6
|
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
-
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters <%= key_value :format, "[:json]" %>
|
9
|
+
end
|
8
10
|
|
11
|
+
<%- unless options.skip_active_record? -%>
|
9
12
|
# Disable root element in JSON by default.
|
10
|
-
|
11
|
-
|
13
|
+
ActiveSupport.on_load(:active_record) do
|
14
|
+
self.include_root_in_json = false
|
12
15
|
end
|
16
|
+
<%- end -%>
|
@@ -11,14 +11,13 @@ module Rails
|
|
11
11
|
def app
|
12
12
|
if mountable?
|
13
13
|
directory "app"
|
14
|
-
template "app/views/layouts/application.html.erb.tt",
|
15
|
-
"app/views/layouts/#{name}/application.html.erb"
|
16
14
|
empty_directory_with_gitkeep "app/assets/images/#{name}"
|
17
15
|
elsif full?
|
18
16
|
empty_directory_with_gitkeep "app/models"
|
19
17
|
empty_directory_with_gitkeep "app/controllers"
|
20
18
|
empty_directory_with_gitkeep "app/views"
|
21
19
|
empty_directory_with_gitkeep "app/helpers"
|
20
|
+
empty_directory_with_gitkeep "app/mailers"
|
22
21
|
empty_directory_with_gitkeep "app/assets/images/#{name}"
|
23
22
|
end
|
24
23
|
end
|
@@ -46,6 +45,7 @@ module Rails
|
|
46
45
|
def lib
|
47
46
|
template "lib/%name%.rb"
|
48
47
|
template "lib/tasks/%name%_tasks.rake"
|
48
|
+
template "lib/%name%/version.rb"
|
49
49
|
if full?
|
50
50
|
template "lib/%name%/engine.rb"
|
51
51
|
end
|
@@ -1,12 +1,27 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require "<%= name %>/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
3
7
|
Gem::Specification.new do |s|
|
4
|
-
s.name
|
5
|
-
s.
|
6
|
-
s.
|
8
|
+
s.name = "<%= name %>"
|
9
|
+
s.version = <%= camelized %>::VERSION
|
10
|
+
s.authors = ["TODO: Your name"]
|
11
|
+
s.email = ["TODO: Your email"]
|
12
|
+
s.homepage = "TODO"
|
13
|
+
s.summary = "TODO: Summary of <%= camelized %>."
|
14
|
+
s.description = "TODO: Description of <%= camelized %>."
|
15
|
+
|
7
16
|
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
|
8
17
|
<% unless options.skip_test_unit? -%>
|
9
18
|
s.test_files = Dir["test/**/*"]
|
10
19
|
<% end -%>
|
11
|
-
|
12
|
-
|
20
|
+
|
21
|
+
<%= '# ' if options.dev? || options.edge? -%>s.add_dependency "rails", "~> <%= Rails::VERSION::STRING %>"
|
22
|
+
<% if full? && !options[:skip_javascript] -%>
|
23
|
+
# s.add_dependency "<%= "#{options[:javascript]}-rails" %>"
|
24
|
+
<% end -%>
|
25
|
+
|
26
|
+
s.add_development_dependency "<%= gem_for_database %>"
|
27
|
+
end
|