From ebb732a7ecc0502299ee5948c31f536c3d6ef15c Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sun, 2 Jan 2011 02:53:15 +0530 Subject: fix typos --- railties/guides/source/routing.textile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile index f60d72352d..1d81c8f95b 100644 --- a/railties/guides/source/routing.textile +++ b/railties/guides/source/routing.textile @@ -498,7 +498,7 @@ You specify a request-based constraint the same way that you specify a segment c match "photos", :constraints => {:subdomain => "admin"} -You can also specify constrains in a block form: +You can also specify constraints in a block form: namespace :admin do @@ -598,7 +598,7 @@ You can specify what Rails should route +"/"+ to with the +root+ method: root :to => 'pages#main' -You should put the +root+ route at the end of the file. You also need to delete the public/index.html.erb file for the root route to take effect. +You should put the +root+ route at the end of the file. You also need to delete the +public/index.html+ file for the root route to take effect. h3. Customizing Resourceful Routes @@ -633,7 +633,7 @@ You can use the +:constraints+ option to specify a required format on the implic resources :photos, :constraints => {:id => /[A-Z][A-Z][0-9]+/} -This declaration constrains the +:id+ parameter to match the supplied regular expression. So, in this case, the router would no longer match +/photos/1+ to this route. Instead, +/photos/RR27+ would match. +This declaration constraints the +:id+ parameter to match the supplied regular expression. So, in this case, the router would no longer match +/photos/1+ to this route. Instead, +/photos/RR27+ would match. You can specify a single constraint to apply to a number of routes by using the block form: -- cgit v1.2.3 From a388c10f96a32d5be6154b813662f1a085ec23f1 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Mon, 3 Jan 2011 02:01:04 +0530 Subject: Fix typos and JavaScript case. --- railties/guides/source/ajax_on_rails.textile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/ajax_on_rails.textile b/railties/guides/source/ajax_on_rails.textile index 972e7ea840..3d7fcdc198 100644 --- a/railties/guides/source/ajax_on_rails.textile +++ b/railties/guides/source/ajax_on_rails.textile @@ -1,10 +1,10 @@ h2. AJAX on Rails -This guide covers the built-in Ajax/Javascript functionality of Rails (and more); it will enable you to create rich and dynamic AJAX applications with ease! We will cover the following topics: +This guide covers the built-in Ajax/JavaScript functionality of Rails (and more); it will enable you to create rich and dynamic AJAX applications with ease! We will cover the following topics: * Quick introduction to AJAX and related technologies -* Handling Javascript the Rails way: Rails helpers, RJS, Prototype and script.aculo.us -* Testing Javascript functionality +* Handling JavaScript the Rails way: Rails helpers, RJS, Prototype and script.aculo.us +* Testing JavaScript functionality endprologue. @@ -12,7 +12,7 @@ h3. Hello AJAX - a Quick Intro If you are a 'show me the code' type of person, you might want to skip this part and jump to the RJS section right away. However, I would really recommend to read it - you'll need the basics of DOM, http requests and other topics discussed here to really understand Ajax on Rails. -h4. Asynchronous Javascript + XML +h4. Asynchronous JavaScript + XML Basic terminology, new style of creating web apps @@ -31,7 +31,7 @@ How do 'standard' and AJAX requests differ, why does this matter for understandi h3. Built-in Rails Helpers -Rails' Javascript framework of choice is "Prototype":http://www.prototypejs.org. Prototype is a generic-purpose Javascript framework that aims to ease the development of dynamic web applications by offering DOM manipulation, AJAX and other Javascript functionality ranging from utility functions to object oriented constructs. It is not specifically written for any language, so Rails provides a set of helpers to enable seamless integration of Prototype with your Rails views. +Rails' JavaScript framework of choice is "Prototype":http://www.prototypejs.org. Prototype is a generic-purpose JavaScript framework that aims to ease the development of dynamic web applications by offering DOM manipulation, AJAX and other JavaScript functionality ranging from utility functions to object oriented constructs. It is not specifically written for any language, so Rails provides a set of helpers to enable seamless integration of Prototype with your Rails views. To get access to these helpers, all you have to do is to include the prototype framework in your pages - typically in your master layout, application.html.erb - like so: @@ -136,7 +136,7 @@ link_to_remote "Add new item", :before => "$('progress').show()", :complete => "$('progress').hide()", :success => "display_item_added(request)", - :failure => "display_error(request)", + :failure => "display_error(request)" ** *:type* If you want to fire a synchronous request for some obscure reason (blocking the browser while the request is processed and doesn't return a status code), you can use the +:type+ option with the value of +:synchronous+. * Finally, using the +html_options+ parameter you can add HTML attributes to the generated tag. It works like the same parameter of the +link_to+ helper. There are interesting side effects for the +href+ and +onclick+ parameters though: @@ -153,7 +153,7 @@ There are three different ways of adding AJAX forms to your view using Rails Pro * +form_remote_tag+ AJAXifies the form by serializing and sending it's data in the background * +submit_to_remote+ and +button_to_remote+ is more rarely used than the previous two. Rather than creating an AJAX form, you add a button/input -Let's se them in action one by one! +Let's see them in action one by one! h5. +remote_form_for+ @@ -183,7 +183,7 @@ h3. JavaScript the Rails way: RJS In the last section we sent some AJAX requests to the server, and inserted the HTML response into the page (with the +:update+ option). However, sometimes a more complicated interaction with the page is needed, which you can either achieve with JavaScript... or with RJS! You are sending JavaScript instructions to the server in both cases, but while in the former case you have to write vanilla JavaScript, in the second you can code Rails, and sit back while Rails generates the JavaScript for you - so basically RJS is a Ruby DSL to write JavaScript in your Rails code. -h4. Javascript without RJS +h4. JavaScript without RJS First we'll check out how to send JavaScript to the server manually. You are practically never going to need this, but it's interesting to understand what's going on under the hood. @@ -329,9 +329,9 @@ h4. Drag and Drop -h3. Testing Javascript +h3. Testing JavaScript -Javascript testing reminds me the definition of the world 'classic' by Mark Twain: "A classic is something that everybody wants to have read and nobody wants to read." It's similar with Javascript testing: everyone would like to have it, yet it's not done by too much developers as it is tedious, complicated, there is a proliferation of tools and no consensus/accepted best practices, but we will nevertheless take a stab at it: +JavaScript testing reminds me the definition of the world 'classic' by Mark Twain: "A classic is something that everybody wants to have read and nobody wants to read." It's similar with JavaScript testing: everyone would like to have it, yet it's not done by too much developers as it is tedious, complicated, there is a proliferation of tools and no consensus/accepted best practices, but we will nevertheless take a stab at it: * (Fire)Watir * Selenium @@ -339,4 +339,4 @@ Javascript testing reminds me the definition of the world 'classic' by Mark Twai * Cucumber+Webrat * Mention stuff like screw.unit/jsSpec -Note to self: check out the RailsConf JS testing video \ No newline at end of file +Note to self: check out the RailsConf JS testing video -- cgit v1.2.3 From 27717655ad7ab4549a5799285975e425e8f80b15 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 3 Jan 2011 12:00:14 +1000 Subject: Re-add "Using initializer files" section to configuring guide --- railties/guides/source/configuring.textile | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'railties/guides/source') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 6e72ae6ead..a3da5e93f1 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -397,6 +397,15 @@ Some parts of Rails can also be configured externally by supplying environment v * +ENV["RAILS_CACHE_ID"]+ and +ENV["RAILS_APP_VERSION"]+ are used to generate expanded cache keys in Rails' caching code. This allows you to have multiple separate caches from the same application. + +h3. Using Initializer Files + +After loading the framework and any gems and plugins in your application, Rails turns to loading initializers. An initializer is any file of Ruby code stored under +config/initializers+ in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks, plugins and gems are loaded, such as options to configure settings for these parts. + +NOTE: You can use subfolders to organize your initializers if you like, because Rails will look into the whole file hierarchy from the initializers folder on down. + +TIP: If you have any ordering dependency in your initializers, you can control the load order by naming. For example, +01_critical.rb+ will be loaded before +02_normal.rb+. + h3. Initialization events Rails has 5 initialization events which can be hooked into (listed in order that they are ran): -- cgit v1.2.3 From a41d33431fa19a08aec52030aeb7225fefe7aa47 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 3 Jan 2011 12:04:21 +1000 Subject: config guide: add basic description for disable_dependency_loading initializer --- railties/guides/source/configuring.textile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index a3da5e93f1..eee18f1131 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -560,8 +560,7 @@ TIP: If you have any ordering dependency in your initializers, you can control t *+set_routes_reloader+* Configures Action Dispatch to reload the routes file using +ActionDispatch::Callbacks.to_prepare+. -*+disable_dependency_loading+* - +*+disable_dependency_loading+* Disables the automatic dependency loading if the +config.cache_classes+ is set to +true+ and +config.dependency_loading+ is set to +false+. h3. Changelog -- cgit v1.2.3 From bc6e1a154a2df3096d36ed3612b0b93c0a466728 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 8 Jan 2011 23:35:36 +0530 Subject: fix template url --- railties/guides/source/generators.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile index 4fec1760c4..3adbbfa7aa 100644 --- a/railties/guides/source/generators.textile +++ b/railties/guides/source/generators.textile @@ -396,7 +396,7 @@ This command will generate the +Thud+ application, and then apply the template t Templates don't have to be stored on the local system, the +-m+ option also supports online templates: - rails new thud -m https://gist.github.com/722911 + rails new thud -m https://gist.github.com/722911.txt Whilst the final section of this guide doesn't cover how to generate the most awesome template known to man, it will take you through the methods available at your disposal so that you can develop it yourself. These same methods are also available for generators. -- cgit v1.2.3 From 4d29816fdad8bd8ed8eb98f12fda6a7b107cc7f4 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sun, 9 Jan 2011 02:24:30 +0530 Subject: fixed query output --- railties/guides/source/active_record_querying.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index 6e45bf3188..22358029d4 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/railties/guides/source/active_record_querying.textile @@ -440,7 +440,7 @@ And this will give you a single +Order+ object for each date where there are ord The SQL that would be executed would be something like this: -SELECT * FROM orders GROUP BY date(created_at) +SELECT * FROM orders GROUP BY date(created_at) ORDER BY created_at h3. Having @@ -664,7 +664,7 @@ Eager loading is the mechanism for loading the associated records of the objects Consider the following code, which finds 10 clients and prints their postcodes: -clients = Client.all(:limit => 10) +clients = Client.limit(10) clients.each do |client| puts client.address.postcode -- cgit v1.2.3 From 31767b003227148ce06b7c8df0f533b7cdeddd9b Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Fri, 14 Jan 2011 22:10:22 +0530 Subject: ends_width => ends_with --- railties/guides/source/active_support_core_extensions.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 9a1f913ded..c283a9bd99 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1264,7 +1264,7 @@ Active Support adds that functionality to % in previous versions of Rub NOTE: Defined in +active_support/core_ext/string/interpolation.rb+. -h4. +starts_with?+ and +ends_width?+ +h4. +starts_with?+ and +ends_with?+ Active Support defines 3rd person aliases of +String#start_with?+ and +String#end_with?+: -- cgit v1.2.3 From 93c208a630e5cd96071ed5581fcd1c23708b3817 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Fri, 14 Jan 2011 22:51:15 +0530 Subject: use new AR api --- railties/guides/source/active_record_basics.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/active_record_basics.textile b/railties/guides/source/active_record_basics.textile index f0081b48c0..b7926f3a3b 100644 --- a/railties/guides/source/active_record_basics.textile +++ b/railties/guides/source/active_record_basics.textile @@ -180,7 +180,7 @@ Active Record provides a rich API for accessing data within a database. Below ar # find all users named David who are Code Artists and sort by created_at in reverse chronological order - users = User.all(:conditions => { :name => 'David', :occupation => 'Code Artist'}, :order => 'created_at DESC') + users = User.where(:name => 'David', :occupation => 'Code Artist').order('created_at DESC') You can learn more about querying an Active Record model in the "Active Record Query Interface":"active_record_querying.html" guide. -- cgit v1.2.3 From 100ab5bd431e1cf9f4fdf08c8724918f482c4684 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 15 Jan 2011 23:39:32 +0530 Subject: Documented the except and only conditions in the guides. Took the cue from Jordi Ramero's commit (b31ef7ee83f3fe808f7534172ce2bf22ef6c7cc0) --- .../guides/source/active_record_querying.textile | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index 22358029d4..64a68f7592 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/railties/guides/source/active_record_querying.textile @@ -19,8 +19,6 @@ Code examples throughout this guide will refer to one or more of the following m TIP: All of the following models use +id+ as the primary key, unless specified otherwise. -
- class Client < ActiveRecord::Base has_one :address @@ -461,6 +459,36 @@ SELECT * FROM orders GROUP BY date(created_at) HAVING created_at > '2009-01-15' This will return single order objects for each day, but only for the last month. +h3. Overriding Conditions + +You can specify certain conditions to be excepted by using the +except+ method. + +For example: + + +Post.where('id > 10').limit(20).order('id asc').except(:order) + + +The SQL that would be executed: + + +SELECT * FROM posts WHERE id > 10 LIMIT 20 + + +You can also override conditions using the +only+ method. + +For example: + + +Post.where('id > 10').limit(20).order('id desc').only(:order, :where) + + +The SQL that would be executed: + + +SELECT * FROM posts WHERE id > 10 ORDER BY id DESC + + h3. Readonly Objects Active Record provides +readonly+ method on a relation to explicitly disallow modification or deletion of any of the returned object. Any attempt to alter or destroy a readonly record will not succeed, raising an +ActiveRecord::ReadOnlyRecord+ exception. -- cgit v1.2.3 From 3c6c2404319931bb27256f190d1f9950149e9a53 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 15 Jan 2011 23:47:41 +0530 Subject: Document the LANGUAGE option for generating guides --- railties/guides/source/ruby_on_rails_guides_guidelines.textile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/ruby_on_rails_guides_guidelines.textile b/railties/guides/source/ruby_on_rails_guides_guidelines.textile index a2e830b574..07f86edfb7 100644 --- a/railties/guides/source/ruby_on_rails_guides_guidelines.textile +++ b/railties/guides/source/ruby_on_rails_guides_guidelines.textile @@ -62,7 +62,13 @@ To force process of all the guides, pass +ALL=1+. It is also recommended that you work with +WARNINGS=1+, this detects duplicate IDs and warns about broken internal links. -h3. HTML validation +If you want to generate guides in languages other than English, you can keep them in a separate directory under +source+ (eg. source/es) and use the +LANGUAGE+ environment variable. + + +rake generate_guides LANGUAGE=es + + +h3. HTML Validation Please do validate the generated HTML with -- cgit v1.2.3 From 77e1a99970c8bd454beaae502d4379309402afa5 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Mon, 17 Jan 2011 00:16:00 +0530 Subject: minor edits --- railties/guides/source/testing.textile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/testing.textile b/railties/guides/source/testing.textile index 733c8a755e..5f0889f406 100644 --- a/railties/guides/source/testing.textile +++ b/railties/guides/source/testing.textile @@ -229,13 +229,13 @@ $ rake db:test:load Above +rake db:migrate+ runs any pending migrations on the _development_ environment and updates +db/schema.rb+. +rake db:test:load+ recreates the test database from the current +db/schema.rb+. On subsequent attempts, it is a good idea to first run +db:test:prepare+, as it first checks for pending migrations and warns you appropriately. -NOTE: +db:test:prepare+ will fail with an error if +db/schema.rb+ doesn't exists. +NOTE: +db:test:prepare+ will fail with an error if +db/schema.rb+ doesn't exist. h5. Rake Tasks for Preparing your Application for Testing |_.Tasks |_.Description| |+rake db:test:clone+ |Recreate the test database from the current environment's database schema| -|+rake db:test:clone_structure+ |Recreate the test databases from the development structure| +|+rake db:test:clone_structure+ |Recreate the test database from the development structure| |+rake db:test:load+ |Recreate the test database from the current +schema.rb+| |+rake db:test:prepare+ |Check for pending migrations and load the test schema| |+rake db:test:purge+ |Empty the test database.| @@ -512,12 +512,12 @@ After a request has been made by using one of the 5 methods (+get+, +post+, etc. As is the case with normal Hash objects, you can access the values by referencing the keys by string. You can also reference them by symbol name, except for +assigns+. For example: - flash["gordon"] flash[:gordon] - session["shmession"] session[:shmession] - cookies["are_good_for_u"] cookies[:are_good_for_u] +flash["gordon"] flash[:gordon] +session["shmession"] session[:shmession] +cookies["are_good_for_u"] cookies[:are_good_for_u] # Because you can't use assigns[:something] for historical reasons: - assigns["something"] assigns(:something) +assigns["something"] assigns(:something) h4. Instance Variables Available -- cgit v1.2.3 From 94e0f1db1cf17aa86fed5d7dad50f9e82238900a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BChlmann?= Date: Wed, 19 Jan 2011 22:03:54 +0100 Subject: use name instead of title in example --- railties/guides/source/i18n.textile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index bb8bf8b240..e47ac7aed6 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -713,12 +713,12 @@ end Then Active Record will look for messages in this order: -activerecord.errors.models.admin.attributes.title.blank +activerecord.errors.models.admin.attributes.name.blank activerecord.errors.models.admin.blank -activerecord.errors.models.user.attributes.title.blank +activerecord.errors.models.user.attributes.name.blank activerecord.errors.models.user.blank activerecord.errors.messages.blank -errors.attributes.title.blank +errors.attributes.name.blank errors.messages.blank -- cgit v1.2.3