From 78497c7c27879aa735db24377f056de96a260bb9 Mon Sep 17 00:00:00 2001 From: Franco Catena Date: Fri, 2 Sep 2011 14:52:58 -0300 Subject: Change photos_path to photos_url in Using redirect_to Is more "correct" a complete url than only the path --- railties/guides/source/layouts_and_rendering.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/layouts_and_rendering.textile b/railties/guides/source/layouts_and_rendering.textile index 3252f17c56..f49c2000ee 100644 --- a/railties/guides/source/layouts_and_rendering.textile +++ b/railties/guides/source/layouts_and_rendering.textile @@ -515,7 +515,7 @@ h4. Using +redirect_to+ Another way to handle returning responses to an HTTP request is with +redirect_to+. As you've seen, +render+ tells Rails which view (or other asset) to use in constructing a response. The +redirect_to+ method does something completely different: it tells the browser to send a new request for a different URL. For example, you could redirect from wherever you are in your code to the index of photos in your application with this call: -redirect_to photos_path +redirect_to photos_url You can use +redirect_to+ with any arguments that you could use with +link_to+ or +url_for+. In addition, there's a special redirect that sends the user back to the page they just came from: -- cgit v1.2.3 From f83f169b85eea4f580ae95609506fbb3cc5b8ccb Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 3 Sep 2011 01:40:00 +0530 Subject: some of the changes for validation earlier reverted from d20281a --- railties/guides/source/active_model_basics.textile | 2 ++ railties/guides/source/active_record_querying.textile | 4 ++-- railties/guides/source/performance_testing.textile | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/active_model_basics.textile b/railties/guides/source/active_model_basics.textile index 0672669dc5..73df567579 100644 --- a/railties/guides/source/active_model_basics.textile +++ b/railties/guides/source/active_model_basics.textile @@ -163,12 +163,14 @@ person.first_name_changed? #=> true Track what was the previous value of the attribute. + #attr_name_was accessor person.first_name_was #=> "First Name" Track both previous and current value of the changed attribute. Returns an array if changed else returns nil + #attr_name_change person.first_name_change #=> ["First Name", "First Name 1"] diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index 4e77a6e803..95a7bfebc3 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/railties/guides/source/active_record_querying.textile @@ -132,7 +132,7 @@ SELECT * FROM clients ORDER BY clients.id DESC LIMIT 1 Model.last returns +nil+ if no matching record is found. No exception will be raised. -h5. +first!+ +h5(#first_1). +first!+ Model.first! finds the first record. For example: @@ -149,7 +149,7 @@ SELECT * FROM clients LIMIT 1 Model.first! raises +RecordNotFound+ if no matching record is found. -h5. +last!+ +h5(#last_1). +last!+ Model.last! finds the last record. For example: diff --git a/railties/guides/source/performance_testing.textile b/railties/guides/source/performance_testing.textile index 75f81cf13d..5947735deb 100644 --- a/railties/guides/source/performance_testing.textile +++ b/railties/guides/source/performance_testing.textile @@ -207,7 +207,7 @@ GC Time measures the amount of time spent in GC for the performance test case. h5. Metric Availability -h6. Benchmarking +h6(#benchmarking_1). Benchmarking |_.Interpreter|_.Wall Time|_.Process Time|_.CPU Time|_.User Time|_.Memory|_.Objects|_.GC Runs|_.GC Time| |_.MRI | yes | yes | yes | no | yes | yes | yes | yes | @@ -215,7 +215,7 @@ h6. Benchmarking |_.Rubinius | yes | no | no | no | yes | yes | yes | yes | |_.JRuby | yes | no | no | yes | yes | yes | yes | yes | -h6. Profiling +h6(#profiling_1). Profiling |_.Interpreter|_.Wall Time|_.Process Time|_.CPU Time|_.User Time|_.Memory|_.Objects|_.GC Runs|_.GC Time| |_.MRI | yes | yes | no | no | yes | yes | yes | yes | -- cgit v1.2.3 From b3a03253a78234dfc3bef0fab7dae2e49c2bfd2a Mon Sep 17 00:00:00 2001 From: David Peckham Date: Fri, 2 Sep 2011 13:38:13 -0700 Subject: Fixed a typo in the section about migration. --- railties/guides/source/getting_started.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile index 256df0eded..6e9613cdae 100644 --- a/railties/guides/source/getting_started.textile +++ b/railties/guides/source/getting_started.textile @@ -592,7 +592,7 @@ class CreatePosts < ActiveRecord::Migration end -The above migration creates a method name +change+ which will be called when you +The above migration creates a method named +change+ which will be called when you run this migration. The action defined in that method is also reversible, which means Rails knows how to reverse the change made by this migration, in case you want to reverse it at later date. By default, when you run this migration it -- cgit v1.2.3 From a3edf3d2a307630980731b1963721c60ba2a14e0 Mon Sep 17 00:00:00 2001 From: Richard Hulse Date: Sat, 3 Sep 2011 09:11:20 +1200 Subject: fix YUI description YUI CSS compressor does not extend syntax! Also added link to more info --- railties/guides/source/asset_pipeline.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index 192c393dca..ef35d1ed76 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -437,7 +437,7 @@ h3. Customizing the Pipeline h4. CSS Compression -There is currently one option for compressing CSS, YUI. This Gem extends the CSS syntax and offers minification. +There is currently one option for compressing CSS, YUI. The "YUI CSS compressor":http://developer.yahoo.com/yui/compressor/css.html provides minification. The following line enables YUI compression, and requires the +yui-compressor+ gem. -- cgit v1.2.3 From 5b7bcb4959a33d7a31acdd2823eb3272bcd1f322 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 3 Sep 2011 02:44:49 +0530 Subject: document send_file guesses content type from the file extension and remove info about x_send_file option to send_file --- railties/guides/source/action_controller_overview.textile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile index 073e3bddcf..4e47712636 100644 --- a/railties/guides/source/action_controller_overview.textile +++ b/railties/guides/source/action_controller_overview.textile @@ -684,9 +684,11 @@ end This will read and stream the file 4kB at the time, avoiding loading the entire file into memory at once. You can turn off streaming with the +:stream+ option or adjust the block size with the +:buffer_size+ option. +If +:type+ is not specified, it will be guessed from the file extension specified in +:filename+. If the content type is not registered for the extension, application/octet-stream will be used. + WARNING: Be careful when using data coming from the client (params, cookies, etc.) to locate the file on disk, as this is a security risk that might allow someone to gain access to files they are not meant to see. -TIP: It is not recommended that you stream static files through Rails if you can instead keep them in a public folder on your web server. It is much more efficient to let the user download the file directly using Apache or another web server, keeping the request from unnecessarily going through the whole Rails stack. Although if you do need the request to go through Rails for some reason, you can set the +:x_sendfile+ option to true, and Rails will let the web server handle sending the file to the user, freeing up the Rails process to do other things. Note that your web server needs to support the +X-Sendfile+ header for this to work. +TIP: It is not recommended that you stream static files through Rails if you can instead keep them in a public folder on your web server. It is much more efficient to let the user download the file directly using Apache or another web server, keeping the request from unnecessarily going through the whole Rails stack. h4. RESTful Downloads -- cgit v1.2.3 From 1b8290db527e29c6b503cb036bc42d67368f766c Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Fri, 2 Sep 2011 17:10:11 -0500 Subject: Fix asset_path example in CSS and ERB section --- railties/guides/source/asset_pipeline.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index ef35d1ed76..82aa0a5256 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -147,7 +147,7 @@ h5. CSS and ERB If you add an +erb+ extension to a CSS asset, making it something such as +application.css.erb+, then you can use the +asset_path+ helper in your CSS rules: -.class { background-image: <%= asset_path 'image.png' %> } +.class { background-image: url(<%= asset_path 'image.png') %> } This writes the path to the particular asset being referenced. In this example, it would make sense to have an image in one of the asset load paths, such as +app/assets/images/image.png+, which would be referenced here. If this image is already available in +public/assets+ as a fingerprinted file, then that path is referenced. -- cgit v1.2.3 From 5014b330288d41680477800847e83e049a5b57c3 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sun, 4 Sep 2011 03:44:47 +0530 Subject: add some missing dots in the docs --- railties/guides/source/configuring.textile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 050fcd823d..ae84bb5b92 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -134,15 +134,15 @@ Rails 3.1, by default, is set up to use the +sprockets+ gem to manage assets wit * +config.assets.prefix+ defines the prefix where assets are served from. Defaults to +/assets+. -* +config.assets.digest+ enables the use of MD5 fingerprints in asset names. Set to +true+ by default in +production.rb+ +* +config.assets.digest+ enables the use of MD5 fingerprints in asset names. Set to +true+ by default in +production.rb+. -* +config.assets.debug+ disables the concatenation and compression of assets. Set to +false+ by default in +development.rb+ +* +config.assets.debug+ disables the concatenation and compression of assets. Set to +false+ by default in +development.rb+. -* +config.assets.manifest+ defines the full path to be used for the asset precompiler's manifest file. Defaults to using +config.assets.prefix+ +* +config.assets.manifest+ defines the full path to be used for the asset precompiler's manifest file. Defaults to using +config.assets.prefix+. * +config.assets.cache_store+ defines the cache store that Sprockets will use. The default is the Rails file store. -* +config.assets.version+ is an option string that is used in MD5 hash generation. This can be changed to force all files to be recompiled. +* +config.assets.version+ is an option string that is used in MD5 hash generation. This can be changed to force all files to be recompiled. * +config.assets.compile+ is a boolean that can be used to turn on live Sprockets compilation in production. -- cgit v1.2.3 From d72ecd92a270823e2fd400066e3c3c55a9bda478 Mon Sep 17 00:00:00 2001 From: Rinaldi Fonseca Date: Sun, 4 Sep 2011 00:34:56 -0300 Subject: Added |t| to create_table block --- railties/guides/source/3_1_release_notes.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/3_1_release_notes.textile b/railties/guides/source/3_1_release_notes.textile index 73a96388af..c4da87dc34 100644 --- a/railties/guides/source/3_1_release_notes.textile +++ b/railties/guides/source/3_1_release_notes.textile @@ -315,7 +315,7 @@ end class MyMigration < ActiveRecord::Migration def change - create_table(:horses) do + create_table(:horses) do |t| t.column :content, :text t.column :remind_at, :datetime end -- cgit v1.2.3 From a6bafb327d403361ef652d6749f0609cfc2a5578 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sun, 4 Sep 2011 18:49:16 +0530 Subject: minor fixes in assets guide --- railties/guides/source/asset_pipeline.textile | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index 82aa0a5256..f287bcd511 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -15,11 +15,11 @@ h3. What is the Asset Pipeline? The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages such as CoffeeScript, Sass and ERB. -Prior to Rails 3.1 these features were added through third-party Ruby libraries such as Jammit and Sprockets. Rails 3.1 is integrated with Sprockets through ActionPack which depends on the +sprockets+ gem, by default. +Prior to Rails 3.1 these features were added through third-party Ruby libraries such as Jammit and Sprockets. Rails 3.1 is integrated with Sprockets through Action Pack which depends on the +sprockets+ gem, by default. By having this as a core feature of Rails, all developers can benefit from the power of having their assets pre-processed, compressed and minified by one central library, Sprockets. This is part of Rails' "Fast by default" strategy as outlined by DHH in his 2011 keynote at Railsconf. -In new Rails 3.1 application the asset pipeline is enabled by default. It can be disabled in +application.rb+ by putting this line inside the +Application+ class definition: +In Rails 3.1, the asset pipeline is enabled by default. It can be disabled in +application.rb+ by putting this line inside the +Application+ class definition: config.assets.enabled = false @@ -308,7 +308,7 @@ NOTE: Under normal circumstances the default option should not be changed. If th h4. Precompiling Assets -Rails comes bundled with a rake task to compile the asset manifests and other files in the pipeline to disc. +Rails comes bundled with a rake task to compile the asset manifests and other files in the pipeline to the disk. Compiled assets are written to the location specified in +config.assets.prefix+. The default setting will use the +public/assets+ directory. @@ -361,7 +361,7 @@ This can be changed with the +config.assets.manifest+ option. A fully specified config.assets.manifest = '/path/to/some/other/location' -NOTE: If there are missing precompiled files in production you will get an "AssetNoPrecompiledError" exception indicating the name of the missing file. +NOTE: If there are missing precompiled files in production you will get an AssetNoPrecompiledError exception indicating the name of the missing file(s). h5. Server Configuration @@ -385,7 +385,7 @@ For Apache: TODO: nginx instructions -When files are precompiled, Sprockets also creates a "Gzip":http://en.wikipedia.org/wiki/Gzip (.gz) version of your assets. This avoids the server having to do this for any requests; it can simply read the compressed files from disc. You must configure your server to use gzip compression and serve the compressed assets that will be stored in the +public/assets+ folder. The following configuration options can be used: +When files are precompiled, Sprockets also creates a "Gzip":http://en.wikipedia.org/wiki/Gzip (.gz) version of your assets. This avoids the server having to do this for any requests; it can simply read the compressed files from disk. You must configure your server to use gzip compression and serve the compressed assets that will be stored in the +public/assets+ folder. The following configuration options can be used: For Apache: @@ -419,7 +419,7 @@ location ~ ^/(assets)/ { h4. Live Compilation -In some circumstances you may wish to use live compilation. In this mode all requests for assets in the Pipeline are handled by Sprockets directly. +In some circumstances you may wish to use live compilation. In this mode all requests for assets in the pipeline are handled by Sprockets directly. To enable this option set: @@ -445,7 +445,7 @@ The following line enables YUI compression, and requires the +yui-compressor+ ge config.assets.css_compressor = :yui -The +config.assets.compress+ must be set to +true+ to enable CSS compression +The +config.assets.compress+ must be set to +true+ to enable CSS compression. h4. JavaScript Compression @@ -539,8 +539,7 @@ config.assets.enabled = true config.assets.version = '1.0' # Change the path that assets are served from -# config.assets.prefix = "/assets" - +# config.assets.prefix = "/assets" In +development.rb+: @@ -584,9 +583,8 @@ The following should also be added to +Gemfile+: # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sass-rails', " ~> 3.1.0" + gem 'sass-rails', "~> 3.1.0" gem 'coffee-rails', "~> 3.1.0" gem 'uglifier' end - -- cgit v1.2.3