Skip to content
This repository
Browse code

Merge branch 'master' of github.com:lifo/docrails

  • Loading branch information...
commit 0d254915819a9e5711895e410e1597177216c903 2 parents d1d5107 + f50aeda
Vijay Dev vijaydev authored
4 actionpack/lib/action_view/helpers/record_tag_helper.rb
@@ -18,7 +18,7 @@ module RecordTagHelper
18 18 # <div id="person_123" class="person foo"> Joe Bloggs </div>
19 19 #
20 20 # You can also pass an array of Active Record objects, which will then
21   - # get iterates over and yield each record as an argument for the block.
  21 + # get iterated over and yield each record as an argument for the block.
22 22 # For example:
23 23 #
24 24 # <%= div_for(@people, :class => "foo") do |person| %>
@@ -56,7 +56,7 @@ def div_for(record, *args, &block)
56 56 # <tr id="foo_person_123" class="person">...
57 57 #
58 58 # You can also pass an array of objects which this method will loop through
59   - # and yield the current object to the supplied block, reduce the need for
  59 + # and yield the current object to the supplied block, reducing the need for
60 60 # having to iterate through the object (using <tt>each</tt>) beforehand.
61 61 # For example (assuming @people is an array of Person objects):
62 62 #
2  railties/guides/source/action_view_overview.textile
Source Rendered
@@ -494,7 +494,7 @@ Will generate this HTML output:
494 494 </tr>
495 495 </html>
496 496
497   -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:
  497 +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:
498 498
499 499 <ruby>
500 500 <%= content_tag_for(:tr, @posts) do |post| %>
66 railties/guides/source/asset_pipeline.textile
Source Rendered
@@ -95,7 +95,7 @@ When a scaffold or controller is generated for the application, Rails also gener
95 95
96 96 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] %>+.
97 97
98   -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.
  98 +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.
99 99
100 100 h4. Asset Organization
101 101
@@ -164,15 +164,33 @@ Note that the closing tag cannot be of the style +-%>+.
164 164
165 165 h5. CSS and Sass
166 166
167   -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.
  167 +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.
168 168
169   -* +image-url("rails.png")+ becomes +url(/assets/rails.png)+
170   -* +image-path("rails.png")+ becomes +"/assets/rails.png"+.
  169 +* +image_url("rails.png")+ becomes +url(/assets/rails.png)+.
  170 +* +image_path("rails.png")+ becomes +"/assets/rails.png"+.
171 171
172 172 The more generic form can also be used but the asset path and class must both be specified:
173 173
174   -* +asset-url("rails.png", image)+ becomes +url(/assets/rails.png)+
175   -* +asset-path("rails.png", image)+ becomes +"/assets/rails.png"+
  174 +* +asset_url("rails.png", image)+ becomes +url(/assets/rails.png)+.
  175 +* +asset_path("rails.png", image)+ becomes +"/assets/rails.png"+.
  176 +
  177 +h5. JavaScript/CoffeeScript and ERB
  178 +
  179 +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:
  180 +
  181 +<plain>
  182 +$('#logo').attr({
  183 + src: "<%= asset_path('logo.png') %>"
  184 +});
  185 +</plain>
  186 +
  187 +This writes the path to the particular asset being referenced.
  188 +
  189 +Similarly, you can use the +asset_path+ helper in CoffeeScript files with +erb+ extension (eg. application.js.coffee.erb):
  190 +
  191 +<plain>
  192 +$('#logo').attr src: "<% asset_path('logo.png') %>"
  193 +</plain>
176 194
177 195 h4. Manifest Files and Directives
178 196
@@ -320,7 +338,7 @@ The rake task is:
320 338 bundle exec rake assets:precompile
321 339 </plain>
322 340
323   -Capistrano (v2.8.0+) has a recipe to handle this in deployment. Add the following line to +Capfile+:
  341 +Capistrano (v2.8.0 and above) has a recipe to handle this in deployment. Add the following line to +Capfile+:
324 342
325 343 <erb>
326 344 load 'deploy/assets'
@@ -330,6 +348,8 @@ This links the folder specified in +config.assets.prefix+ to +shared/assets+. If
330 348
331 349 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.
332 350
  351 +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).
  352 +
333 353 The default matcher for compiling files includes +application.js+, +application.css+ and all files that do not end in +js+ or +css+:
334 354
335 355 <ruby>
@@ -342,7 +362,7 @@ If you have other manifests or individual stylesheets and JavaScript files to in
342 362 config.assets.precompile += ['admin.js', 'admin.css', 'swfObject.js']
343 363 </erb>
344 364
345   -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:
  365 +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:
346 366
347 367 <plain>
348 368 ---
@@ -394,16 +414,16 @@ For Apache:
394 414 # 2 lines to serve pre-gzipped version
395 415 RewriteCond %{REQUEST_FILENAME}.gz -s
396 416 RewriteRule ^(.+) $1.gz [L]
397   -
398   - # without it, Content-Type will be "application/x-gzip"
399   - <FilesMatch .*\.css.gz>
400   - ForceType text/css
401   - </FilesMatch>
402   -
403   - <FilesMatch .*\.js.gz>
404   - ForceType text/javascript
405   - </FilesMatch>
406 417 </LocationMatch>
  418 +
  419 +# without these, Content-Type will be "application/x-gzip"
  420 +<FilesMatch "^/assets/.*\.css.gz$">
  421 + ForceType text/css
  422 +</FilesMatch>
  423 +
  424 +<FilesMatch "^/assets/.*\.js.gz$">
  425 + ForceType text/javascript
  426 +</FilesMatch>
407 427 </plain>
408 428
409 429 For nginx:
@@ -431,7 +451,15 @@ On the first request the assets are compiled and cached as outlined in developme
431 451
432 452 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.
433 453
434   -This mode uses more memory and is lower performance than the default. It is not recommended.
  454 +This mode uses more memory, performs poorer than the default and is not recommended.
  455 +
  456 +When deploying a production application to a system without any pre-existing JavaScript runtimes, you may want to add one to your Gemfile:
  457 +
  458 +<plain>
  459 +group :production do
  460 + gem 'therubyracer'
  461 +end
  462 +</plain>
435 463
436 464 h3. Customizing the Pipeline
437 465
@@ -461,7 +489,7 @@ config.assets.js_compressor = :uglifier
461 489
462 490 The +config.assets.compress+ must be set to +true+ to enable JavaScript compression
463 491
464   -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.
  492 +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.
465 493
466 494 h4. Using Your Own Compressor
467 495
2  railties/guides/source/contributing_to_ruby_on_rails.textile
Source Rendered
@@ -284,7 +284,7 @@ $ cd rails
284 284 $ git checkout -b my_new_branch
285 285 </shell>
286 286
287   -It doesn’t really matter what name you use, because this branch will only exist on your local computer.
  287 +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.
288 288
289 289 h4. Write Your Code
290 290
10 railties/guides/source/getting_started.textile
Source Rendered
@@ -61,9 +61,9 @@ The Rails philosophy includes several guiding principles:
61 61
62 62 * DRY - "Don't Repeat Yourself" - suggests that writing the same code over and over again is a bad thing.
63 63 * Convention Over Configuration - means that Rails makes assumptions about what you want to do and how you're going to
64   -d o it, rather than requiring you to specify every little thing through endless configuration files.
  64 +do it, rather than requiring you to specify every little thing through endless configuration files.
65 65 * REST is the best pattern for web applications - organizing your application around resources and standard HTTP verbs
66   -i s the fastest way to go.
  66 +is the fastest way to go.
67 67
68 68 h4. The MVC Architecture
69 69
@@ -549,9 +549,9 @@ folders, and edit <tt>config/routes.rb</tt>. Here's a quick overview of what it
549 549 |app/views/posts/new.html.erb |A view to create a new post|
550 550 |app/views/posts/_form.html.erb |A partial to control the overall look and feel of the form used in edit and new views|
551 551 |app/helpers/posts_helper.rb |Helper functions to be used from the post views|
552   -|app/assets/stylesheets/scaffold.css.scss |Cascading style sheet to make the scaffolded views look better|
553   -|app/assets/stylesheets/post.css.scss |Cascading style sheet for the posts controller|
554   -|app/assets/javascripts/post.js.coffee |CoffeeScript for the posts controller|
  552 +|app/assets/stylesheets/scaffolds.css.scss |Cascading style sheet to make the scaffolded views look better|
  553 +|app/assets/stylesheets/posts.css.scss |Cascading style sheet for the posts controller|
  554 +|app/assets/javascripts/posts.js.coffee |CoffeeScript for the posts controller|
555 555 |test/unit/post_test.rb |Unit testing harness for the posts model|
556 556 |test/functional/posts_controller_test.rb |Functional testing harness for the posts controller|
557 557 |test/unit/helpers/posts_helper_test.rb |Unit testing harness for the posts helper|

0 comments on commit 0d25491

Please sign in to comment.
Something went wrong with that request. Please try again.