From 59462c1e310b85569785cf5f491611e670c2755b Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Mon, 7 May 2012 12:25:21 +0200 Subject: Initial proof reading of getting started guide --- guides/source/getting_started.textile | 41 +++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index 947abd7ba0..264cde51bd 100644 --- a/guides/source/getting_started.textile +++ b/guides/source/getting_started.textile @@ -334,7 +334,10 @@ When you call +form_for+, you pass it an identifying object for this form. In th There's one problem with this form though. If you inspect the HTML that is generated, by viewing the source of the page, you will see that the +action+ attribute for the form is pointing at +/posts/new+. This is a problem because this route goes to the very page that you're on right at the moment, and that route should only be used to display the form for a new post. -So the form needs to use a different URL in order to go somewhere else. This can be done quite simply with the +:url+ option of +form_for+. Typically in Rails, the action that is used for new form submissions like this is called "create", and so the form should be pointed to this action. +The form needs to use a different URL in order to go somewhere else. +This can be done quite simply with the +:url+ option of +form_for+. +Typically in Rails, the action that is used for new form submissions +like this is called "create", and so the form should be pointed to that action. Edit the +form_for+ line inside +app/views/posts/new.html.erb+ to look like this: @@ -350,11 +353,11 @@ post "posts/create" By using the +post+ method rather than the +get+ method, Rails will define a route that will only respond to POST methods. The POST method is the typical method used by forms all over the web. -With the form and the route for it defined now, you will be able to fill in the form and then click the submit button to begin the process of creating a new post, so go ahead and do that. When you submit the form, you should see a familiar error: +With the form and its associated route defined, you will be able to fill in the form and then click the submit button to begin the process of creating a new post, so go ahead and do that. When you submit the form, you should see a familiar error: !images/getting_started/unknown_action_create_for_posts.png(Unknown action create for PostsController)! -You will now need to create the +create+ action within the +PostsController+ for this to work. +You now need to create the +create+ action within the +PostsController+ for this to work. h4. Creating posts @@ -381,7 +384,7 @@ def create end -The +render+ method here is taking a very simple hash with the key of +text+ and the value of +params[:post].inspect+. The +params+ method here is the object which represents the parameters (or fields) coming in from the form. The +params+ method returns a +HashWithIndifferentAccess+ object, which allows you to access the keys of the hash using either strings or symbols. In this situation, the only parameters that matter are the ones from the form. +The +render+ method here is taking a very simple hash with a key of +text+ and value of +params[:post].inspect+. The +params+ method is the object which represents the parameters (or fields) coming in from the form. The +params+ method returns a +HashWithIndifferentAccess+ object, which allows you to access the keys of the hash using either strings or symbols. In this situation, the only parameters that matter are the ones from the form. If you re-submit the form one more time you'll now no longer get the missing template error. Instead, you'll see something that looks like the following: @@ -402,14 +405,15 @@ To create the new model, run this command in your terminal: $ rails generate model Post title:string text:text -With that command we told Rails that we want a +Post+ model, which in -turn should have a title attribute of type string, and a text attribute +With that command we told Rails that we want a +Post+ model, which +should have a _title_ attribute of type string, and a _text_ attribute of type text. Those attributes are automatically added to the +posts+ table in the database and mapped to the +Post+ model. -Rails in turn responded by creating a bunch of files. For +Rails responded by creating a bunch of files. For now, we're only interested in +app/models/post.rb+ and -+db/migrate/20120419084633_create_posts.rb+. The latter is responsible ++db/migrate/20120419084633_create_posts.rb+ (your name could be a bit +different). The latter is responsible for creating the database structure, which is what we'll look at next. h4. Running a Migration @@ -472,8 +476,8 @@ invoking the command: +rake db:migrate RAILS_ENV=production+. h4. Saving data in the controller Back in +posts_controller+, we need to change the +create+ action -to use the new +Post+ model to save data in the database. Open that file -and change the +create+ action to look like the following: +to use the new +Post+ model to save the data in the database. Open that file +and change the +create+ action to look like this: def create @@ -485,22 +489,21 @@ end Here's what's going on: every Rails model can be initialized with its -respective attributes, which are automatically mapped to its +respective attributes, which are automatically mapped to the respective database columns. In the first line we do just that (remember that +params[:post]+ contains the attributes we're interested in). Then, +@post.save+ is responsible for saving the model in the database. -Finally, on the last line we redirect the user to the +show+ action, -wich we have not defined yet. +Finally, we redirect the user to the +show+ action, +wich we'll define later. TIP: As we'll see later, +@post.save+ returns a boolean indicating -wherever the model was saved or not, and you can (and usually do) take -different actions depending on the result of calling +@post.save+. +wherever the model was saved or not. -h4. Showing posts +h4. Showing Posts -Before trying to create a new post, let's add the +show+ action, which -will be responsible for showing our posts. Open +config/routes.rb+ -and add the following route: +If you submit the form again now, Rails will complain about not finding +the +show+ action. That's not very useful though, so let's aff the ++show+ action before proceeding. Open +config/routes.rb+ and add the following route: get "posts/:id" => "posts#show" -- cgit v1.2.3 From 26e2c082595ecca360954cfc20ecc52221748f7b Mon Sep 17 00:00:00 2001 From: Richard Hulse Date: Sun, 13 May 2012 14:16:50 +1200 Subject: [guides] add local precompilation section --- guides/source/asset_pipeline.textile | 37 +++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/asset_pipeline.textile b/guides/source/asset_pipeline.textile index 010154f1d1..59f106acb2 100644 --- a/guides/source/asset_pipeline.textile +++ b/guides/source/asset_pipeline.textile @@ -396,7 +396,7 @@ Rails comes bundled with a rake task to compile the asset manifests and other fi Compiled assets are written to the location specified in +config.assets.prefix+. By default, this is the +public/assets+ directory. -You can call this task on the server during deployment to create compiled versions of your assets directly on the server. If you do not have write access to your production file system, you can call this task locally and then deploy the compiled assets. +You can call this task on the server during deployment to create compiled versions of your assets directly on the server. See the next section for information on compiling locally. The rake task is: @@ -516,6 +516,41 @@ If you're compiling nginx with Phusion Passenger you'll need to pass that option A robust configuration for Apache is possible but tricky; please Google around. (Or help update this Guide if you have a good example configuration for Apache.) +h4. Local Precompilation + +There are several reasons why you might precompile your assets locally. Among them are: + +* You may not have write access to your production file system. +* You may be deploying to more than one server, and want to avoid the duplication of work. +* You may be doing frequent deploys that do not include asset changes. + +Local compilation allows you to commit the compiled files into source control, and deploy as normal. + +There are two caveats: + +* You must not run the Capistrano deployment task. +* You must change the following two application configuration settings. + +In development.rb place the following line: + + +config.assets.prefix = "/dev-assets" + + +You will also need this in application.rb: + + +config.assets.initialize_on_precompile = false + + +The +prefix+ change makes rails use a different URL for serving assets in development mode, and so pass all requests to Sprockets. Production is still set to +/assets+. Without this changes the application would serve the precompiled assets in development, and you would not see any local changes until you next compiled assets. + +The +initialize_on_precompile+ change tell the precompile task to run without invoking Rails. + +You will also need to ensure that any compressors or minifers are available on you development system. + +In practice, this will allow you to precompile locally, have those files in your working tree, and commit those files to source control when needed. Development mode will work as expected. + 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. -- cgit v1.2.3 From e6e6f4ef8675ea001801362b42cdabb13801da67 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 14 May 2012 06:52:50 +1000 Subject: Briefly explain static file routing in the getting started guide --- guides/source/getting_started.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index 1e9bd1f144..bdd385918f 100644 --- a/guides/source/getting_started.textile +++ b/guides/source/getting_started.textile @@ -193,7 +193,7 @@ Now that we have made the controller and view, we need to tell Rails when we wan To fix this, delete the +index.html+ file located inside the +public+ directory of the application. -You need to do this because Rails will serve any static file in the +public+ directory that matches a route in preference to any dynamic content you generate from the controllers. +You need to do this because Rails will serve any static file in the +public+ directory that matches a route in preference to any dynamic content you generate from the controllers. The +index.html+ file is special: it will be served if a request comes in at the root route, e.g. http://localhost:3000. If another request such as http://localhost:3000/welcome happened, a static file at public/welcome.html would be served first, but only if it existed. Next, you have to tell Rails where your actual home page is located. -- cgit v1.2.3 From 9e4fd33ae8860388cff54af44ee07f19a09ba9f6 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 14 May 2012 06:54:40 +1000 Subject: Re-enforce/re-explain what happens when you go to root route (Welcome#index) better --- guides/source/getting_started.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index bdd385918f..a689cf1c3b 100644 --- a/guides/source/getting_started.textile +++ b/guides/source/getting_started.textile @@ -210,7 +210,7 @@ Blog::Application.routes.draw do The +root :to => "welcome#index"+ tells Rails to map requests to the root of the application to the welcome controller's index action. This was created earlier when you ran the controller generator (+rails generate controller welcome index+). -If you navigate to "http://localhost:3000":http://localhost:3000 in your browser, you'll see +Hello, Rails!+. +If you navigate to "http://localhost:3000":http://localhost:3000 in your browser, you'll see the +Hello, Rails!+ message you put into +app/views/welcome/index.html.erb+, indicating that this new route is indeed going to +WelcomeController+'s +index+ action and is rendering the view correctly. NOTE. For more information about routing, refer to "Rails Routing from the Outside In":routing.html. -- cgit v1.2.3 From 96fb77fe8000569ccc6b5bfd91668719bf92fa3d Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 14 May 2012 06:55:45 +1000 Subject: Separate CR out in CRUD explanation, explain each letter one at a time --- guides/source/getting_started.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index a689cf1c3b..540084eb15 100644 --- a/guides/source/getting_started.textile +++ b/guides/source/getting_started.textile @@ -220,7 +220,7 @@ Now that you've seen how to create a controller, an action and a view, let's cre In the Blog application, you will now create a new _resource_. A resource is the term used for a collection of similar objects, such as posts, people or animals. You can create, read, update and destroy items for a resource and these operations are referred to as _CRUD_ operations. -In the next section, you will add the ability to create new posts in your application and be able to view them. This is the "CR" from CRUD. The form for doing this will look like this: +In the next section, you will add the ability to create new posts in your application and be able to view them. This is the "C" and the "R" from CRUD: creation and reading. The form for doing this will look like this: !images/getting_started/new_post.png(The new post form)! -- cgit v1.2.3 From dbd131fc0e9394438eb0e76796c89160a924b7ef Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 14 May 2012 06:56:43 +1000 Subject: Rails actually has one root route defined --- guides/source/getting_started.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index 540084eb15..3a5868b13e 100644 --- a/guides/source/getting_started.textile +++ b/guides/source/getting_started.textile @@ -232,7 +232,7 @@ The first thing that you are going to need to create a new post within the appli !images/getting_started/routing_error_no_route_matches.png(A routing error, no route matches /posts/new)! -This is because there is nowhere inside the routes for the application -- defined inside +config/routes.rb+ -- that defines this route. By default, Rails has no routes configured at all, and so you must define your routes as you need them. +This is because there is nowhere inside the routes for the application -- defined inside +config/routes.rb+ -- that defines this route. By default, Rails has no routes configured at all, besides the root route you defined earlier, and so you must define your routes as you need them. To do this, you're going to need to create a route inside +config/routes.rb+ file, on a new line between the +do+ and the +end+ for the +draw+ method: -- cgit v1.2.3 From 5f7caff82572daa2adc9a83f280b58572b3ba3e2 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 14 May 2012 07:02:58 +1000 Subject: Wrap 'Missing template posts/new' error message in a blockquote for better formatting --- guides/source/getting_started.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index 3a5868b13e..6a07f87abd 100644 --- a/guides/source/getting_started.textile +++ b/guides/source/getting_started.textile @@ -282,9 +282,9 @@ You're getting this error now because Rails expects plain actions like this one In the above image, the bottom line has been truncated. Let's see what the full thing looks like: - +
Missing template posts/new, application/new with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "/path/to/blog/app/views" - +
That's quite a lot of text! Let's quickly go through and understand what each part of it does. -- cgit v1.2.3 From d4801d0229515aae37d8f7a2f72c83990d2d977b Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 14 May 2012 07:06:41 +1000 Subject: Correct code wrapping around content of welcome/index.html.erb --- guides/source/getting_started.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index 6a07f87abd..84c438e607 100644 --- a/guides/source/getting_started.textile +++ b/guides/source/getting_started.textile @@ -183,9 +183,9 @@ Rails will create several files for you. Most important of these are of course t Open the +app/views/welcome/index.html.erb+ file in your text editor and edit it to contain a single line of code: - +

Hello, Rails!

-
+ h4. Setting the Application Home Page -- cgit v1.2.3 From 8ef67de03409d0d21e42605e063e501d3ee764cf Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Mon, 14 May 2012 15:17:59 +0530 Subject: fix format in getting started guide [ci skip] --- guides/source/getting_started.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index 84c438e607..e89602218e 100644 --- a/guides/source/getting_started.textile +++ b/guides/source/getting_started.textile @@ -193,7 +193,7 @@ Now that we have made the controller and view, we need to tell Rails when we wan To fix this, delete the +index.html+ file located inside the +public+ directory of the application. -You need to do this because Rails will serve any static file in the +public+ directory that matches a route in preference to any dynamic content you generate from the controllers. The +index.html+ file is special: it will be served if a request comes in at the root route, e.g. http://localhost:3000. If another request such as http://localhost:3000/welcome happened, a static file at public/welcome.html would be served first, but only if it existed. +You need to do this because Rails will serve any static file in the +public+ directory that matches a route in preference to any dynamic content you generate from the controllers. The +index.html+ file is special: it will be served if a request comes in at the root route, e.g. http://localhost:3000. If another request such as http://localhost:3000/welcome happened, a static file at public/welcome.html would be served first, but only if it existed. Next, you have to tell Rails where your actual home page is located. -- cgit v1.2.3 From ee4e48eab06659b3fea64c70590e8d260a230445 Mon Sep 17 00:00:00 2001 From: Ayrton De Craene Date: Mon, 14 May 2012 13:24:32 +0200 Subject: Improved the readability of some sentences [ci skip] --- guides/source/i18n.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/i18n.textile b/guides/source/i18n.textile index 6179694c40..a9da843d04 100644 --- a/guides/source/i18n.textile +++ b/guides/source/i18n.textile @@ -127,7 +127,7 @@ If you want to translate your Rails application to a *single language other than However, you would probably like to *provide support for more locales* in your application. In such case, you need to set and pass the locale between requests. -WARNING: You may be tempted to store the chosen locale in a _session_ or a cookie. *Do not do so*. The locale should be transparent and a part of the URL. This way you don't break people's basic assumptions about the web itself: if you send a URL of some page to a friend, she should see the same page, same content. A fancy word for this would be that you're being "RESTful":http://en.wikipedia.org/wiki/Representational_State_Transfer. Read more about the RESTful approach in "Stefan Tilkov's articles":http://www.infoq.com/articles/rest-introduction. There may be some exceptions to this rule, which are discussed below. +WARNING: You may be tempted to store the chosen locale in a _session_ or a cookie, however *do not do this*. The locale should be transparent and a part of the URL. This way you won't break people's basic assumptions about the web itself: if you send a URL to a friend, they should see the same page and content as you. A fancy word for this would be that you're being "RESTful":http://en.wikipedia.org/wiki/Representational_State_Transfer. Read more about the RESTful approach in "Stefan Tilkov's articles":http://www.infoq.com/articles/rest-introduction. Sometimes there are exceptions to this rule and those are discussed below. The _setting part_ is easy. You can set the locale in a +before_filter+ in the +ApplicationController+ like this: -- cgit v1.2.3 From 888383e0accf376109f29020c7f8cfbaa39338b9 Mon Sep 17 00:00:00 2001 From: Ayrton De Craene Date: Mon, 14 May 2012 14:04:24 +0200 Subject: 'Netherlands locale' does not make any sense, it's Dutch locale [ci skip] --- guides/source/i18n.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides/source') diff --git a/guides/source/i18n.textile b/guides/source/i18n.textile index a9da843d04..ee7176a6c8 100644 --- a/guides/source/i18n.textile +++ b/guides/source/i18n.textile @@ -220,7 +220,7 @@ Every helper method dependent on +url_for+ (e.g. helpers for named routes like + You may be satisfied with this. It does impact the readability of URLs, though, when the locale "hangs" at the end of every URL in your application. Moreover, from the architectural standpoint, locale is usually hierarchically above the other parts of the application domain: and URLs should reflect this. -You probably want URLs to look like this: +www.example.com/en/books+ (which loads the English locale) and +www.example.com/nl/books+ (which loads the Netherlands locale). This is achievable with the "over-riding +default_url_options+" strategy from above: you just have to set up your routes with "+path_prefix+":http://api.rubyonrails.org/classes/ActionController/Resources.html#M000354 option in this way: +You probably want URLs to look like this: +www.example.com/en/books+ (which loads the English locale) and +www.example.com/nl/books+ (which loads the Dutch locale). This is achievable with the "over-riding +default_url_options+" strategy from above: you just have to set up your routes with "+path_prefix+":http://api.rubyonrails.org/classes/ActionController/Resources.html#M000354 option in this way: # config/routes.rb @@ -229,7 +229,7 @@ scope "/:locale" do end -Now, when you call the +books_path+ method you should get +"/en/books"+ (for the default locale). An URL like +http://localhost:3001/nl/books+ should load the Netherlands locale, then, and following calls to +books_path+ should return +"/nl/books"+ (because the locale changed). +Now, when you call the +books_path+ method you should get +"/en/books"+ (for the default locale). An URL like +http://localhost:3001/nl/books+ should load the Dutch locale, then, and following calls to +books_path+ should return +"/nl/books"+ (because the locale changed). If you don't want to force the use of a locale in your routes you can use an optional path scope (denoted by the parentheses) like so: -- cgit v1.2.3 From 151aa9abae131f1a03513f756aeaef2fc403f9bb Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Mon, 14 May 2012 21:49:42 +0300 Subject: remove docs on Range#step --- guides/source/active_support_core_extensions.textile | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'guides/source') diff --git a/guides/source/active_support_core_extensions.textile b/guides/source/active_support_core_extensions.textile index 8045316e98..bf30ed64c8 100644 --- a/guides/source/active_support_core_extensions.textile +++ b/guides/source/active_support_core_extensions.textile @@ -2767,18 +2767,6 @@ As the example depicts, the +:db+ format generates a +BETWEEN+ SQL clause. That NOTE: Defined in +active_support/core_ext/range/conversions.rb+. -h4. +step+ - -Active Support extends the method +Range#step+ so that it can be invoked without a block: - - -(1..10).step(2) # => [1, 3, 5, 7, 9] - - -As the example shows, in that case the method returns an array with the corresponding elements. - -NOTE: Defined in +active_support/core_ext/range/blockless_step.rb+. - h4. +include?+ The methods +Range#include?+ and +Range#===+ say whether some value falls between the ends of a given instance: -- cgit v1.2.3 From c4b00879f00986520e10afcb167bf643fcce07ea Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Mon, 14 May 2012 14:14:59 -0700 Subject: Minor editing of getting started guide --- guides/source/getting_started.textile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index f76fdce58b..6d847575c4 100644 --- a/guides/source/getting_started.textile +++ b/guides/source/getting_started.textile @@ -330,7 +330,10 @@ method called +form_for+. To use this method, add this code into +app/views/post If you refresh the page now, you'll see the exact same form as in the example. Building forms in Rails is really just that easy! -When you call +form_for+, you pass it an identifying object for this form. In this case, it's the symbol +:post+. This tells the +form_for+ helper what this form is for. Inside the block for this method, the FormBuilder object -- represented by +f+ -- is used to build two labels and two text fields, one each for the title and text of a post. Finally, a call to +submit+ on the +f+ object will create a submit button for the form. +When you call +form_for+, you pass it an identifying object for this +form. In this case, it's the symbol +:post+. This tells the +form_for+ +helper what this form is for. Inside the block for this method, the ++FormBuilder+ object -- represented by +f+ -- is used to build two labels and two text fields, one each for the title and text of a post. Finally, a call to +submit+ on the +f+ object will create a submit button for the form. There's one problem with this form though. If you inspect the HTML that is generated, by viewing the source of the page, you will see that the +action+ attribute for the form is pointing at +/posts/new+. This is a problem because this route goes to the very page that you're on right at the moment, and that route should only be used to display the form for a new post. @@ -405,8 +408,8 @@ To create the new model, run this command in your terminal: $ rails generate model Post title:string text:text -With that command we told Rails that we want a +Post+ model, which -should have a _title_ attribute of type string, and a _text_ attribute +With that command we told Rails that we want a +Post+ model, together +with a _title_ attribute of type string, and a _text_ attribute of type text. Those attributes are automatically added to the +posts+ table in the database and mapped to the +Post+ model. @@ -416,6 +419,11 @@ now, we're only interested in +app/models/post.rb+ and different). The latter is responsible for creating the database structure, which is what we'll look at next. +TIP: Active Record is smart enough to automatically map column names to +model attributes, which means you don't have to declare attributes +inside Rails models, as that will be done automatically by Active +Record. + h4. Running a Migration As we've just seen, +rails generate model+ created a _database -- cgit v1.2.3 From b83f4c74531373421852d83babb27775d14dd9b3 Mon Sep 17 00:00:00 2001 From: Mark Rushakoff Date: Mon, 14 May 2012 22:33:45 -0700 Subject: s/aff/add [ci skip] --- guides/source/getting_started.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index 6d847575c4..e93a94448a 100644 --- a/guides/source/getting_started.textile +++ b/guides/source/getting_started.textile @@ -510,7 +510,7 @@ wherever the model was saved or not. h4. Showing Posts If you submit the form again now, Rails will complain about not finding -the +show+ action. That's not very useful though, so let's aff the +the +show+ action. That's not very useful though, so let's add the +show+ action before proceeding. Open +config/routes.rb+ and add the following route: -- cgit v1.2.3 From 632f279ec063a8c1e0168e82ce5c5cbd6ae1db4e Mon Sep 17 00:00:00 2001 From: Mark Rushakoff Date: Mon, 14 May 2012 22:37:34 -0700 Subject: code-format italicized 'production' env [ci skip] --- guides/source/configuring.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/configuring.textile b/guides/source/configuring.textile index b2c9300034..f114075cae 100644 --- a/guides/source/configuring.textile +++ b/guides/source/configuring.textile @@ -597,7 +597,7 @@ Rails has 5 initialization events which can be hooked into (listed in the order * +to_prepare+: Run after the initializers are run for all Railties (including the application itself), but before eager loading and the middleware stack is built. More importantly, will run upon every request in +development+, but only once (during boot-up) in +production+ and +test+. -* +before_eager_load+: This is run directly before eager loading occurs, which is the default behaviour for the _production_ environment and not for the +development+ environment. +* +before_eager_load+: This is run directly before eager loading occurs, which is the default behaviour for the +production+ environment and not for the +development+ environment. * +after_initialize+: Run directly after the initialization of the application, but before the application initializers are run. -- cgit v1.2.3 From 8972829a91c6ff1b6653399e49cf82a682b2b0e9 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Tue, 15 May 2012 13:00:25 +0530 Subject: copy edit asset guide [ci skip] --- guides/source/asset_pipeline.textile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'guides/source') diff --git a/guides/source/asset_pipeline.textile b/guides/source/asset_pipeline.textile index 59f106acb2..116a0a371a 100644 --- a/guides/source/asset_pipeline.textile +++ b/guides/source/asset_pipeline.textile @@ -518,7 +518,7 @@ A robust configuration for Apache is possible but tricky; please Google around. h4. Local Precompilation -There are several reasons why you might precompile your assets locally. Among them are: +There are several reasons why you might want to precompile your assets locally. Among them are: * You may not have write access to your production file system. * You may be deploying to more than one server, and want to avoid the duplication of work. @@ -528,10 +528,10 @@ Local compilation allows you to commit the compiled files into source control, a There are two caveats: -* You must not run the Capistrano deployment task. +* You must not run the Capistrano deployment task that precompiles assets. * You must change the following two application configuration settings. -In development.rb place the following line: +In config/environments/development.rb, place the following line: config.assets.prefix = "/dev-assets" @@ -543,11 +543,9 @@ You will also need this in application.rb: config.assets.initialize_on_precompile = false -The +prefix+ change makes rails use a different URL for serving assets in development mode, and so pass all requests to Sprockets. Production is still set to +/assets+. Without this changes the application would serve the precompiled assets in development, and you would not see any local changes until you next compiled assets. +The +prefix+ change makes Rails use a different URL for serving assets in development mode, and pass all requests to Sprockets. The prefix is still set to +/assets+ in the production environment. Without this change, the application would serve the precompiled assets from +public/assets+ in development, and you would not see any local changes until you compile assets again. -The +initialize_on_precompile+ change tell the precompile task to run without invoking Rails. - -You will also need to ensure that any compressors or minifers are available on you development system. +The +initialize_on_precompile+ change tell the precompile task to run without invoking Rails. You will also need to ensure that any compressors or minifiers are available on your development system. In practice, this will allow you to precompile locally, have those files in your working tree, and commit those files to source control when needed. Development mode will work as expected. -- cgit v1.2.3