diff --git a/railties/doc/guides/source/association_basics.txt b/railties/doc/guides/source/association_basics.txt index 39d92be2d2d18..95d73975582b5 100644 --- a/railties/doc/guides/source/association_basics.txt +++ b/railties/doc/guides/source/association_basics.txt @@ -416,9 +416,9 @@ This declaration needs to be backed up by the proper foreign key declaration on class CreateOrders < ActiveRecord::Migration def self.up create_table :orders do |t| - t.order_date :datetime - t.order_number :string - t.customer_id :integer + t.datetime :order_date + t.string :order_number + t.integer :customer_id end end diff --git a/railties/doc/guides/source/getting_started_with_rails.txt b/railties/doc/guides/source/getting_started_with_rails.txt index 9adcc729a385a..b66d2f6f9e5ef 100644 --- a/railties/doc/guides/source/getting_started_with_rails.txt +++ b/railties/doc/guides/source/getting_started_with_rails.txt @@ -154,6 +154,13 @@ And if you're using PostgreSQL for data storage, run this command: $ rails blog -d postgresql ------------------------------------------------------- +After you create the blog application, switch to its folder to continue work directly in that application: + +[source, shell] +------------------------------------------------------- +$ cd blog +------------------------------------------------------- + In any case, Rails will create a folder in your working directory called +blog+. Open up that folder and explore its contents. Most of the work in this tutorial will happen in the +app/+ folder, but here's a basic rundown on the function of each folder that Rails creates in a new application by default: [grid="all"] @@ -239,6 +246,15 @@ development: Change the username and password in the +development+ section as appropriate. +==== Creating the Database + +Now that you have your database configured, it's time to have Rails create an empty database for you. You can do this by running a rake command: + +[source, shell] +------------------------------------------------------- +$ rake db:create +------------------------------------------------------- + == Hello, Rails! One of the traditional places to start with a new language is by getting some text up on screen quickly. To do that in Rails, you need to create at minimum a controller and a view. Fortunately, you can do that in a single command. Enter this command in your terminal: @@ -370,7 +386,7 @@ end If you were to translate that into words, it says something like: when this migration is run, create a table named +posts+ with two string columns (+name+ and +title+) and a text column (+content+), and generate timestamp fields to track record creation and updating. You can learn the detailed syntax for migrations in the link:../migrations.html[Rails Database Migrations] guide. -At this point, you need to do two things: create the database and run the migration. You can use rake commands at the terminal for both of those tasks: +At this point, you can use a rake command to run the migration: [source, shell] ------------------------------------------------------- @@ -378,7 +394,7 @@ $ rake db:create $ rake db:migrate ------------------------------------------------------- -NOTE: Because you're working in the development environment by default, both of these commands will apply to the database defined in the +development+ section of your +config/database.yml+ file. +NOTE: Because you're working in the development environment by default, this command will apply to the database defined in the +development+ section of your +config/database.yml+ file. === Adding a Link @@ -748,7 +764,7 @@ At this point, it’s worth looking at some of the tools that Rails provides to === Using Partials to Eliminate View Duplication -As you saw earlier, the scaffold-generated views for the +new+ and +edit+ actions are largely identical. You can pull the shared code out into a +partial+ template. This requires editing the new and edit views, and adding a new template: +As you saw earlier, the scaffold-generated views for the +new+ and +edit+ actions are largely identical. You can pull the shared code out into a +partial+ template. This requires editing the new and edit views, and adding a new template. The new +_form.html.erb+ template should be saved in the same +app/views/posts+ folder as the files from which it is being extracted: +new.html.erb+: diff --git a/railties/doc/guides/source/routing_outside_in.txt b/railties/doc/guides/source/routing_outside_in.txt index 4086fd0cbdd8a..3f6c80de5c293 100644 --- a/railties/doc/guides/source/routing_outside_in.txt +++ b/railties/doc/guides/source/routing_outside_in.txt @@ -738,7 +738,7 @@ You do not need to explicitly use the +:controller+ and +:action+ symbols within [source, ruby] ------------------------------------------------------- -map.connect 'photo/:id', :controller => 'photos', :action => 'show' +map.connect 'photos/:id', :controller => 'photos', :action => 'show' ------------------------------------------------------- With this route, an incoming URL of +/photos/12+ would be dispatched to the +show+ action within the +Photos+ controller. @@ -747,7 +747,7 @@ You an also define other defaults in a route by supplying a hash for the +:defau [source, ruby] ------------------------------------------------------- -map.connect 'photo/:id', :controller => 'photos', :action => 'show', :defaults => { :format => 'jpg' } +map.connect 'photos/:id', :controller => 'photos', :action => 'show', :defaults => { :format => 'jpg' } ------------------------------------------------------- With this route, an incoming URL of +photos/12+ would be dispatched to the +show+ action within the +Photos+ controller, and +params[:format]+ will be set to +jpg+. @@ -886,7 +886,7 @@ For better readability, you can specify an already-created route in your call to [source, ruby] ------------------------------------------------------- -map.index :controller => "pages", :action => "main" +map.index 'index', :controller => "pages", :action => "main" map.root :index -------------------------------------------------------