From 2c07baf284268883b5a287ff341d361815e5e4df Mon Sep 17 00:00:00 2001 From: Rashmi Yadav Date: Sun, 14 Jul 2013 22:55:56 +0200 Subject: Using ruby 1.9 syntax [ci skip] --- guides/source/debugging_rails_applications.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides/source') diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md index 98f91c1ac6..77a2dd4b18 100644 --- a/guides/source/debugging_rails_applications.md +++ b/guides/source/debugging_rails_applications.md @@ -301,7 +301,7 @@ This command shows you where you are in the code by printing 10 lines centered a 7 8 respond_to do |format| 9 format.html # index.html.erb - 10 format.json { render :json => @posts } + 10 format.json { render json: @posts } ``` If you repeat the `list` command, this time using just `l`, the next ten lines of the file will be printed out. @@ -337,7 +337,7 @@ On the other hand, to see the previous ten lines you should type `list-` (or `l- 7 8 respond_to do |format| 9 format.html # index.html.erb - 10 format.json { render :json => @posts } + 10 format.json { render json: @posts } ``` This way you can move inside the file, being able to see the code above and over the line you added the `debugger`. -- cgit v1.2.3 From 9ed7013a3dc74a9701aa2591396f0944807cf432 Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Mon, 15 Jul 2013 10:35:00 +0200 Subject: Rack Sendfile is coming as default now --- guides/source/rails_on_rack.md | 1 + 1 file changed, 1 insertion(+) (limited to 'guides/source') diff --git a/guides/source/rails_on_rack.md b/guides/source/rails_on_rack.md index d144fba762..73f541bda4 100644 --- a/guides/source/rails_on_rack.md +++ b/guides/source/rails_on_rack.md @@ -119,6 +119,7 @@ $ rake middleware For a freshly generated Rails application, this might produce something like: ```ruby +use Rack::Sendfile use ActionDispatch::Static use Rack::Lock use # -- cgit v1.2.3 From 86fd83770ff07967b420085af2f496bc1d28678b Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Mon, 15 Jul 2013 11:51:51 +0200 Subject: Added Rack::Sendfile in rake about [ci skip] --- guides/source/command_line.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/command_line.md b/guides/source/command_line.md index 218b4dd39a..6eadbe8435 100644 --- a/guides/source/command_line.md +++ b/guides/source/command_line.md @@ -384,7 +384,7 @@ Active Record version 4.0.0 Action Pack version 4.0.0 Action Mailer version 4.0.0 Active Support version 4.0.0 -Middleware ActionDispatch::Static, Rack::Lock, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::EncryptedCookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag +Middleware Rack::Sendfile, ActionDispatch::Static, Rack::Lock, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::EncryptedCookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag Application root /home/foobar/commandsapp Environment development Database adapter sqlite3 -- cgit v1.2.3 From fd8890058e22a95642b14f3efcb32396bcf90a5e Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Wed, 17 Jul 2013 12:04:14 +0200 Subject: Guides fixed typo in index.html.erb file [ci skip] --- guides/source/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index c785fd1f8c..cdb25a1013 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -953,7 +953,7 @@ appear next to the "Show" link: <%= post.title %> <%= post.text %> - <%= link_to 'Show', post_path(post) %> + <%= link_to 'Show', post %> <%= link_to 'Edit', edit_post_path(post) %> <% end %> -- cgit v1.2.3 From e7485752e6fb6dce59362ec4320876c59b027e96 Mon Sep 17 00:00:00 2001 From: Rashmi Yadav Date: Wed, 17 Jul 2013 17:47:08 +0200 Subject: New output for scaffold generate [ci skip] --- guides/source/command_line.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'guides/source') diff --git a/guides/source/command_line.md b/guides/source/command_line.md index 6eadbe8435..911c832952 100644 --- a/guides/source/command_line.md +++ b/guides/source/command_line.md @@ -222,7 +222,7 @@ We will set up a simple resource called "HighScore" that will keep track of our ```bash $ rails generate scaffold HighScore game:string score:integer invoke active_record - create db/migrate/20120528060026_create_high_scores.rb + create db/migrate/20130717151933_create_high_scores.rb create app/models/high_score.rb invoke test_unit create test/models/high_score_test.rb @@ -244,18 +244,21 @@ $ rails generate scaffold HighScore game:string score:integer create app/helpers/high_scores_helper.rb invoke test_unit create test/helpers/high_scores_helper_test.rb + invoke jbuilder + create app/views/high_scores/index.json.jbuilder + create app/views/high_scores/show.json.jbuilder invoke assets invoke coffee create app/assets/javascripts/high_scores.js.coffee invoke scss create app/assets/stylesheets/high_scores.css.scss invoke scss - create app/assets/stylesheets/scaffolds.css.scss + identical app/assets/stylesheets/scaffolds.css.scss ``` The generator checks that there exist the directories for models, controllers, helpers, layouts, functional and unit tests, stylesheets, creates the views, controller, model and database migration for HighScore (creating the `high_scores` table and fields), takes care of the route for the **resource**, and new tests for everything. -The migration requires that we **migrate**, that is, run some Ruby code (living in that `20120528060026_create_high_scores.rb`) to modify the schema of our database. Which database? The sqlite3 database that Rails will create for you when we run the `rake db:migrate` command. We'll talk more about Rake in-depth in a little while. +The migration requires that we **migrate**, that is, run some Ruby code (living in that `20130717151933_create_high_scores.rb`) to modify the schema of our database. Which database? The sqlite3 database that Rails will create for you when we run the `rake db:migrate` command. We'll talk more about Rake in-depth in a little while. ```bash $ rake db:migrate -- cgit v1.2.3 From d49c00027ec8aec1e51f2190abf641e33813c7da Mon Sep 17 00:00:00 2001 From: Rajarshi Das Date: Thu, 18 Jul 2013 11:04:21 +0530 Subject: fixes the test case of that plugins --- guides/source/plugins.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'guides/source') diff --git a/guides/source/plugins.md b/guides/source/plugins.md index 695f25f8a9..9077e424c8 100644 --- a/guides/source/plugins.md +++ b/guides/source/plugins.md @@ -68,7 +68,7 @@ In this example you will add a method to String named `to_squawk`. To begin, cre require 'test_helper' -class CoreExtTest < Test::Unit::TestCase +class CoreExtTest < ActiveSupport::TestCase def test_to_squawk_prepends_the_word_squawk assert_equal "squawk! Hello World", "Hello World".to_squawk end @@ -136,7 +136,7 @@ To begin, set up your files so that you have: require 'test_helper' -class ActsAsYaffleTest < Test::Unit::TestCase +class ActsAsYaffleTest < ActiveSupport::TestCase end ``` @@ -173,7 +173,7 @@ To start out, write a failing test that shows the behavior you'd like: require 'test_helper' -class ActsAsYaffleTest < Test::Unit::TestCase +class ActsAsYaffleTest < ActiveSupport::TestCase def test_a_hickwalls_yaffle_text_field_should_be_last_squawk assert_equal "last_squawk", Hickwall.yaffle_text_field @@ -321,7 +321,7 @@ To start out, write a failing test that shows the behavior you'd like: # yaffle/test/acts_as_yaffle_test.rb require 'test_helper' -class ActsAsYaffleTest < Test::Unit::TestCase +class ActsAsYaffleTest < ActiveSupport::TestCase def test_a_hickwalls_yaffle_text_field_should_be_last_squawk assert_equal "last_squawk", Hickwall.yaffle_text_field -- cgit v1.2.3 From 760662de868c0311f2e40a5e6f8982a521a3d990 Mon Sep 17 00:00:00 2001 From: Mikhail Dieterle Date: Fri, 19 Jul 2013 10:54:24 +0300 Subject: use strong_params in example --- guides/source/engines.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/engines.md b/guides/source/engines.md index bc66ed256e..d8120fe244 100644 --- a/guides/source/engines.md +++ b/guides/source/engines.md @@ -393,10 +393,15 @@ The form will be making a `POST` request to `/posts/:post_id/comments`, which wi ```ruby def create @post = Post.find(params[:post_id]) - @comment = @post.comments.create(params[:comment]) + @comment = @post.comments.create(comment_params) flash[:notice] = "Comment has been created!" redirect_to posts_path end + +private +def comment_params + params.require(:comment).permit(:text) +end ``` This is the final part required to get the new comment form working. Displaying the comments however, is not quite right yet. If you were to create a comment right now you would see this error: -- cgit v1.2.3