From 14157b779b9f65bb9d39cb38b100776f2fe1f194 Mon Sep 17 00:00:00 2001 From: Ray Baxter Date: Sun, 4 Sep 2011 13:34:07 -0700 Subject: clarify where the branch name will exist --- railties/guides/source/contributing_to_ruby_on_rails.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/contributing_to_ruby_on_rails.textile b/railties/guides/source/contributing_to_ruby_on_rails.textile index 4706725bb6..c302d393aa 100644 --- a/railties/guides/source/contributing_to_ruby_on_rails.textile +++ b/railties/guides/source/contributing_to_ruby_on_rails.textile @@ -284,7 +284,7 @@ $ cd rails $ git checkout -b my_new_branch -It doesn’t really matter what name you use, because this branch will only exist on your local computer. +It doesn’t really matter what name you use, because this branch will only exist on your local computer and your personal repository on Github. It won't be part of the Rails git repository. h4. Write Your Code -- cgit v1.2.3 From 0a2ea92efa52165d6b840f2f18382484388389d2 Mon Sep 17 00:00:00 2001 From: Hendy Tanata Date: Mon, 5 Sep 2011 08:05:06 +0800 Subject: Fix grammar for content_tag_for and div_for docs. --- railties/guides/source/action_view_overview.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/action_view_overview.textile b/railties/guides/source/action_view_overview.textile index d1827c649b..edaaeb8543 100644 --- a/railties/guides/source/action_view_overview.textile +++ b/railties/guides/source/action_view_overview.textile @@ -494,7 +494,7 @@ Will generate this HTML output: -You can pass a collection of Active Record objects. This method will loops through your objects and create a container for each of them. For example, given +@posts+ is an array of two +Post+ objects: +You can pass a collection of Active Record objects. This method will loop through your objects and create a container for each of them. For example, given +@posts+ is an array of two +Post+ objects: <%= content_tag_for(:tr, @posts) do |post| %> -- cgit v1.2.3 From 3e62235c6c384775c0a12ba5683eba37fee8acd9 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Sun, 4 Sep 2011 20:56:47 -0500 Subject: Add JavaScript and ERB section to Asset Guide --- railties/guides/source/asset_pipeline.textile | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'railties') diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index 54464cdf4d..69b8d43f55 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -174,6 +174,18 @@ The more generic form can also be used but the asset path and class must both be * +asset-url("rails.png", image)+ becomes +url(/assets/rails.png)+ * +asset-path("rails.png", image)+ becomes +"/assets/rails.png"+ +h5. JavaScript and ERB + +If you add an +erb+ extension to a JavaScript asset, making it something such as +application.js.erb+, then you can use the +asset_path+ helper in your JavaScript code: + + +$('#logo').attr({ + src: "<%= asset_path('logo.png') %>" +}); + + +This writes the path to the particular asset being referenced. + h4. Manifest Files and Directives Sprockets uses manifest files to determine which assets to include and serve. These manifest files contain _directives_ -- instructions that tell Sprockets which files to require in order to build a single CSS or JavaScript file. With these directives, Sprockets loads the files specified, processes them if necessary, concatenates them into one single file and then compresses them (if +Rails.application.config.assets.compress+ is set to +true+). By serving one file rather than many, the load time of pages are greatly reduced as there are fewer requests to make. -- cgit v1.2.3 From a1dbd94b60ee4118e4706f7bb3a416fcc215e0b5 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Sun, 4 Sep 2011 21:01:04 -0500 Subject: Add CoffeeScript example to JavaScript and ERB section --- railties/guides/source/asset_pipeline.textile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index 69b8d43f55..fdb18651dc 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -174,7 +174,7 @@ The more generic form can also be used but the asset path and class must both be * +asset-url("rails.png", image)+ becomes +url(/assets/rails.png)+ * +asset-path("rails.png", image)+ becomes +"/assets/rails.png"+ -h5. JavaScript and ERB +h5. JavaScript/CoffeeScript and ERB If you add an +erb+ extension to a JavaScript asset, making it something such as +application.js.erb+, then you can use the +asset_path+ helper in your JavaScript code: @@ -186,6 +186,12 @@ $('#logo').attr({ This writes the path to the particular asset being referenced. +Similary, you can use the asset_path helper in CoffeeScript files with +erb+ extension (Eg. application.js.coffee.erb): + + +$('#logo').attr src: "<% asset_path('logo.png') %>" + + h4. Manifest Files and Directives Sprockets uses manifest files to determine which assets to include and serve. These manifest files contain _directives_ -- instructions that tell Sprockets which files to require in order to build a single CSS or JavaScript file. With these directives, Sprockets loads the files specified, processes them if necessary, concatenates them into one single file and then compresses them (if +Rails.application.config.assets.compress+ is set to +true+). By serving one file rather than many, the load time of pages are greatly reduced as there are fewer requests to make. -- cgit v1.2.3 From 8df4fb1bb4e5109f734f396625efd8446253fbd4 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Sun, 4 Sep 2011 21:17:23 -0500 Subject: Add reference about "bundle install --without assets" in Precompiling Assets section. --- railties/guides/source/asset_pipeline.textile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties') diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index fdb18651dc..1b2e81dc8b 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -348,6 +348,8 @@ This links the folder specified in +config.assets.prefix+ to +shared/assets+. If It is important that this folder is shared between deployments so that remotely cached pages that reference the old compiled assets still work for the life of the cached page. +Note: If you are precompiling your assets locally you can use +bundle install --without assets+ when installing the gems on the server to avoid install of the assets gems (the gems in the assets group in the Gemfile). + The default matcher for compiling files includes +application.js+, +application.css+ and all files that do not end in +js+ or +css+: -- cgit v1.2.3 From a76c23e6bec3e418b9845010fc4c9f997abe1a01 Mon Sep 17 00:00:00 2001 From: dharmatech Date: Mon, 5 Sep 2011 04:07:48 -0500 Subject: getting_started.textile: fix minor typo --- 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 6e9613cdae..e17b1ee1ee 100644 --- a/railties/guides/source/getting_started.textile +++ b/railties/guides/source/getting_started.textile @@ -63,7 +63,7 @@ The Rails philosophy includes several guiding principles: * Convention Over Configuration - means that Rails makes assumptions about what you want to do and how you're going to d o it, rather than requiring you to specify every little thing through endless configuration files. * REST is the best pattern for web applications - organizing your application around resources and standard HTTP verbs -i s the fastest way to go. +is the fastest way to go. h4. The MVC Architecture -- cgit v1.2.3 From 9584e15d3967a9fd4b38dca26db2de68add96dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=A3is=20Ozols?= Date: Tue, 6 Sep 2011 17:13:30 +0300 Subject: Change hyphen to underscore. --- railties/guides/source/asset_pipeline.textile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index 1b2e81dc8b..1448776c25 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -166,13 +166,13 @@ h5. CSS and Sass When using the asset pipeline, paths to assets must be re-written and +sass-rails+ provides +_url+ and +_path+ helpers for the following asset classes: image, font, video, audio, javascript, stylesheet. -* +image-url("rails.png")+ becomes +url(/assets/rails.png)+ -* +image-path("rails.png")+ becomes +"/assets/rails.png"+. +* +image_url("rails.png")+ becomes +url(/assets/rails.png)+ +* +image_path("rails.png")+ becomes +"/assets/rails.png"+. The more generic form can also be used but the asset path and class must both be specified: -* +asset-url("rails.png", image)+ becomes +url(/assets/rails.png)+ -* +asset-path("rails.png", image)+ becomes +"/assets/rails.png"+ +* +asset_url("rails.png", image)+ becomes +url(/assets/rails.png)+ +* +asset_path("rails.png", image)+ becomes +"/assets/rails.png"+ h5. JavaScript/CoffeeScript and ERB -- cgit v1.2.3 From 5e2bf4de62014820798b271e97fa010ddc1a7e02 Mon Sep 17 00:00:00 2001 From: Marcus Ilgner Date: Tue, 6 Sep 2011 16:27:26 +0200 Subject: Fixed Apache configuration for gzipped assets: FilesMatch and LocationMatch cannot be nested. --- railties/guides/source/asset_pipeline.textile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index 1448776c25..e4f1e0c41a 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -414,16 +414,16 @@ For Apache: # 2 lines to serve pre-gzipped version RewriteCond %{REQUEST_FILENAME}.gz -s RewriteRule ^(.+) $1.gz [L] - - # without it, Content-Type will be "application/x-gzip" - - ForceType text/css - - - - ForceType text/javascript - + +# without these, Content-Type will be "application/x-gzip" + + ForceType text/css + + + + ForceType text/javascript + For nginx: -- cgit v1.2.3 From 198092e2c0a703ca983893aa4527317b3442b5b1 Mon Sep 17 00:00:00 2001 From: Ryan Walker Date: Tue, 6 Sep 2011 14:06:34 -0300 Subject: Added note about adding a javascript runtime to Gemfile for production environment. --- railties/guides/source/asset_pipeline.textile | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'railties') diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index e4f1e0c41a..b6f8d607b9 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -608,3 +608,11 @@ group :assets do gem 'uglifier' end + +Rails 3.1 requires "execjs":https://github.com/sstephenson/execjs - but it doesn't provide a default javascript runtime. When deploying a production app to a system without a pre-existing javascript runtime, you may want to add: + + +group :production do + gem 'therubyracer' +end + -- cgit v1.2.3 From 760fd1eb42038a64591036fc5d687afc98f272aa Mon Sep 17 00:00:00 2001 From: Joost Baaij Date: Wed, 7 Sep 2011 16:09:56 +0300 Subject: Rails.root is a Pathname, no need to use File.join first. --- 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 b6f8d607b9..f2b93be35f 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -112,7 +112,7 @@ All subdirectories that exist within these three locations are added to the sear You can add additional (fully qualified) paths to the pipeline in +application.rb+. For example: -config.assets.paths << File.join(Rails.root, 'app', 'assets', 'flash') +config.assets.paths << Rails.root.join('app', 'assets', 'flash') h4. Coding Links to Assets -- cgit v1.2.3 From 98b55ee2e3d89a050359a52bcc203bfe4fbc39ed Mon Sep 17 00:00:00 2001 From: dharmatech Date: Wed, 7 Sep 2011 09:09:11 -0500 Subject: getting_started.textile: Fix another typo --- 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 e17b1ee1ee..e3488cee1f 100644 --- a/railties/guides/source/getting_started.textile +++ b/railties/guides/source/getting_started.textile @@ -61,7 +61,7 @@ The Rails philosophy includes several guiding principles: * DRY - "Don't Repeat Yourself" - suggests that writing the same code over and over again is a bad thing. * Convention Over Configuration - means that Rails makes assumptions about what you want to do and how you're going to -d o it, rather than requiring you to specify every little thing through endless configuration files. +do it, rather than requiring you to specify every little thing through endless configuration files. * REST is the best pattern for web applications - organizing your application around resources and standard HTTP verbs is the fastest way to go. -- cgit v1.2.3 From 0fb3aa750f9980d26b1fe386c3f6cc0bd0bc23e5 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 7 Sep 2011 22:32:49 +0530 Subject: copy edit assets guide --- railties/guides/source/asset_pipeline.textile | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index f2b93be35f..e5a08bbed5 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -95,7 +95,7 @@ When a scaffold or controller is generated for the application, Rails also gener For example, if a +ProjectsController+ is generated, there will be a new file at +app/assets/javascripts/projects.js.coffee+ and another at +app/assets/stylesheets/projects.css.scss+. You should put any JavaScript or CSS unique to a controller inside their respective asset files, as these files can then be loaded just for these controllers with lines such as +<%= javascript_include_tag params[:controller] %>+ or +<%= stylesheet_link_tag params[:controller] %>+. -NOTE: You will need a "ExecJS":https://github.com/sstephenson/execjs#readme - supported runtime in order to use CoffeeScript. If you are using Mac OS X or Windows you have a JavaScript runtime installed in your operating system. Check "ExecJS":https://github.com/sstephenson/execjs#readme documentation to know all supported JavaScript runtimes. +NOTE: You will need a "ExecJS":https://github.com/sstephenson/execjs#readme supported runtime in order to use CoffeeScript. If you are using Mac OS X or Windows you have a JavaScript runtime installed in your operating system. Check "ExecJS":https://github.com/sstephenson/execjs#readme documentation to know all supported JavaScript runtimes. h4. Asset Organization @@ -164,15 +164,15 @@ Note that the closing tag cannot be of the style +-%>+. h5. CSS and Sass -When using the asset pipeline, paths to assets must be re-written and +sass-rails+ provides +_url+ and +_path+ helpers for the following asset classes: image, font, video, audio, javascript, stylesheet. +When using the asset pipeline, paths to assets must be re-written and +sass-rails+ provides +_url+ and +_path+ helpers for the following asset classes: image, font, video, audio, JavaScript and stylesheet. -* +image_url("rails.png")+ becomes +url(/assets/rails.png)+ +* +image_url("rails.png")+ becomes +url(/assets/rails.png)+. * +image_path("rails.png")+ becomes +"/assets/rails.png"+. The more generic form can also be used but the asset path and class must both be specified: -* +asset_url("rails.png", image)+ becomes +url(/assets/rails.png)+ -* +asset_path("rails.png", image)+ becomes +"/assets/rails.png"+ +* +asset_url("rails.png", image)+ becomes +url(/assets/rails.png)+. +* +asset_path("rails.png", image)+ becomes +"/assets/rails.png"+. h5. JavaScript/CoffeeScript and ERB @@ -186,7 +186,7 @@ $('#logo').attr({ This writes the path to the particular asset being referenced. -Similary, you can use the asset_path helper in CoffeeScript files with +erb+ extension (Eg. application.js.coffee.erb): +Similarly, you can use the +asset_path+ helper in CoffeeScript files with +erb+ extension (eg. application.js.coffee.erb): $('#logo').attr src: "<% asset_path('logo.png') %>" @@ -338,7 +338,7 @@ The rake task is: bundle exec rake assets:precompile -Capistrano (v2.8.0+) has a recipe to handle this in deployment. Add the following line to +Capfile+: +Capistrano (v2.8.0 and above) has a recipe to handle this in deployment. Add the following line to +Capfile+: load 'deploy/assets' @@ -348,7 +348,7 @@ This links the folder specified in +config.assets.prefix+ to +shared/assets+. If It is important that this folder is shared between deployments so that remotely cached pages that reference the old compiled assets still work for the life of the cached page. -Note: If you are precompiling your assets locally you can use +bundle install --without assets+ when installing the gems on the server to avoid install of the assets gems (the gems in the assets group in the Gemfile). +NOTE. If you are precompiling your assets locally, you can use +bundle install --without assets+ on the server to avoid installing the assets gems (the gems in the assets group in the Gemfile). The default matcher for compiling files includes +application.js+, +application.css+ and all files that do not end in +js+ or +css+: @@ -362,7 +362,7 @@ If you have other manifests or individual stylesheets and JavaScript files to in config.assets.precompile += ['admin.js', 'admin.css', 'swfObject.js'] -The rake task also generates a +manifest.yml+ that contains a list with all your assets and their respective fingerprints. This is used by the Rails helper methods and avoids handing the mapping requests back to Sprockets. Manifest file typically look like this: +The rake task also generates a +manifest.yml+ that contains a list with all your assets and their respective fingerprints. This is used by the Rails helper methods and avoids handing the mapping requests back to Sprockets. A typical manifest file looks like: --- @@ -451,7 +451,15 @@ On the first request the assets are compiled and cached as outlined in developme Sprockets also sets the +Cache-Control+ HTTP header to +max-age=31536000+. This signals all caches between your server and the client browser that this content (the file served) can be cached for 1 year. The effect of this is to reduce the number of requests for this asset from your server; the asset has a good chance of being in the local browser cache or some intermediate cache. -This mode uses more memory and is lower performance than the default. It is not recommended. +This mode uses more memory, performs poorer than the default and is not recommended. + +When deploying a production application to a system without any pre-existing JavaScript runtimes, you may want to add one to your Gemfile: + + +group :production do + gem 'therubyracer' +end + h3. Customizing the Pipeline @@ -481,7 +489,7 @@ config.assets.js_compressor = :uglifier The +config.assets.compress+ must be set to +true+ to enable JavaScript compression -NOTE: You will need a "ExecJS":https://github.com/sstephenson/execjs#readme -- supported runtime in order to use +uglifier+. If you are using Mac OS X or Windows you have installed a JavaScript runtime in your operating system. Check "ExecJS":https://github.com/sstephenson/execjs#readme documentation to know all supported JavaScript runtimes. +NOTE: You will need a "ExecJS":https://github.com/sstephenson/execjs#readme supported runtime in order to use +uglifier+. If you are using Mac OS X or Windows you have installed a JavaScript runtime in your operating system. Check "ExecJS":https://github.com/sstephenson/execjs#readme documentation to know all supported JavaScript runtimes. h4. Using Your Own Compressor @@ -608,11 +616,3 @@ group :assets do gem 'uglifier' end - -Rails 3.1 requires "execjs":https://github.com/sstephenson/execjs - but it doesn't provide a default javascript runtime. When deploying a production app to a system without a pre-existing javascript runtime, you may want to add: - - -group :production do - gem 'therubyracer' -end - -- cgit v1.2.3 From 190a2bf9c482fef8412982ea31a755d7e59f17b6 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 7 Sep 2011 22:33:04 +0530 Subject: Revert "Rails.root is a Pathname, no need to use File.join first." This reverts commit 760fd1eb42038a64591036fc5d687afc98f272aa. Reason: We need a fully qualified path string here, not a Pathname. --- 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 e5a08bbed5..bad1c08747 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -112,7 +112,7 @@ All subdirectories that exist within these three locations are added to the sear You can add additional (fully qualified) paths to the pipeline in +application.rb+. For example: -config.assets.paths << Rails.root.join('app', 'assets', 'flash') +config.assets.paths << File.join(Rails.root, 'app', 'assets', 'flash') h4. Coding Links to Assets -- cgit v1.2.3 From f50aeda2f73b47c47664e3651c638ba624418b8b Mon Sep 17 00:00:00 2001 From: dharmatech Date: Wed, 7 Sep 2011 20:23:28 -0500 Subject: getting_started.textile section 6: Correct file names in table --- railties/guides/source/getting_started.textile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile index e3488cee1f..f4a61482c6 100644 --- a/railties/guides/source/getting_started.textile +++ b/railties/guides/source/getting_started.textile @@ -549,9 +549,9 @@ folders, and edit config/routes.rb. Here's a quick overview of what it |app/views/posts/new.html.erb |A view to create a new post| |app/views/posts/_form.html.erb |A partial to control the overall look and feel of the form used in edit and new views| |app/helpers/posts_helper.rb |Helper functions to be used from the post views| -|app/assets/stylesheets/scaffold.css.scss |Cascading style sheet to make the scaffolded views look better| -|app/assets/stylesheets/post.css.scss |Cascading style sheet for the posts controller| -|app/assets/javascripts/post.js.coffee |CoffeeScript for the posts controller| +|app/assets/stylesheets/scaffolds.css.scss |Cascading style sheet to make the scaffolded views look better| +|app/assets/stylesheets/posts.css.scss |Cascading style sheet for the posts controller| +|app/assets/javascripts/posts.js.coffee |CoffeeScript for the posts controller| |test/unit/post_test.rb |Unit testing harness for the posts model| |test/functional/posts_controller_test.rb |Functional testing harness for the posts controller| |test/unit/helpers/posts_helper_test.rb |Unit testing harness for the posts helper| -- cgit v1.2.3