Follow-up to #15215 [ci skip]

This commit is contained in:
Robin Dupret 2014-06-27 16:50:41 +02:00
parent 2053e1f8da
commit 11ac0cad08
3 changed files with 12 additions and 10 deletions

View File

@ -159,10 +159,10 @@ class ArticlesController < ApplicationController
def create def create
@article = Article.new(params[:article]) @article = Article.new(params[:article])
logger.debug "New article: #{@article.attributes.inspect}" logger.debug "New article: #{@article.attributes.inspect}"
logger.debug Article should be valid: #{@article.valid?}" logger.debug "Article should be valid: #{@article.valid?}"
if @article.save if @article.save
flash[:notice] = Article was successfully created.' flash[:notice] = 'Article was successfully created.'
logger.debug "The article was saved and now the user is going to be redirected..." logger.debug "The article was saved and now the user is going to be redirected..."
redirect_to(@article) redirect_to(@article)
else else
@ -184,7 +184,8 @@ vbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA=--b18cd92fba90eacf8137e
"body"=>"I'm learning how to print in logs!!!", "published"=>"0"}, "body"=>"I'm learning how to print in logs!!!", "published"=>"0"},
"authenticity_token"=>"2059c1286e93402e389127b1153204e0d1e275dd", "action"=>"create", "controller"=>"articles"} "authenticity_token"=>"2059c1286e93402e389127b1153204e0d1e275dd", "action"=>"create", "controller"=>"articles"}
New article: {"updated_at"=>nil, "title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs!!!", New article: {"updated_at"=>nil, "title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs!!!",
"published"=>false, "created_at"=>nil} Article should be valid: true "published"=>false, "created_at"=>nil}
Article should be valid: true
Article Create (0.000443) INSERT INTO "articles" ("updated_at", "title", "body", "published", Article Create (0.000443) INSERT INTO "articles" ("updated_at", "title", "body", "published",
"created_at") VALUES('2008-09-08 14:52:54', 'Debugging Rails', "created_at") VALUES('2008-09-08 14:52:54', 'Debugging Rails',
'I''m learning how to print in logs!!!', 'f', '2008-09-08 14:52:54') 'I''m learning how to print in logs!!!', 'f', '2008-09-08 14:52:54')

View File

@ -394,7 +394,7 @@ end
``` ```
This helps prevent conflicts with any other engine or application that may have This helps prevent conflicts with any other engine or application that may have
a article resource as well. an article resource as well.
Finally, the assets for this resource are generated in two files: Finally, the assets for this resource are generated in two files:
`app/assets/javascripts/blorgh/articles.js` and `app/assets/javascripts/blorgh/articles.js` and
@ -506,8 +506,8 @@ NOTE: Because the `has_many` is defined inside a class that is inside the
model for these objects, so there's no need to specify that using the model for these objects, so there's no need to specify that using the
`:class_name` option here. `:class_name` option here.
Next, there needs to be a form so that comments can be created on a article. To add Next, there needs to be a form so that comments can be created on an article. To
this, put this line underneath the call to `render @article.comments` in add this, put this line underneath the call to `render @article.comments` in
`app/views/blorgh/articles/show.html.erb`: `app/views/blorgh/articles/show.html.erb`:
```erb ```erb
@ -739,9 +739,10 @@ the application. In the case of the `blorgh` engine, making articles and comment
have authors would make a lot of sense. have authors would make a lot of sense.
A typical application might have a `User` class that would be used to represent A typical application might have a `User` class that would be used to represent
authors for a article or a comment. But there could be a case where the application authors for an article or a comment. But there could be a case where the
calls this class something different, such as `Person`. For this reason, the application calls this class something different, such as `Person`. For this
engine should not hardcode associations specifically for a `User` class. reason, the engine should not hardcode associations specifically for a `User`
class.
To keep it simple in this case, the application will have a class called `User` To keep it simple in this case, the application will have a class called `User`
that represents the users of the application. It can be generated using this that represents the users of the application. It can be generated using this

View File

@ -585,7 +585,7 @@ Here's another example that uses `flash`, `assert_redirected_to`, and `assert_di
```ruby ```ruby
test "should create article" do test "should create article" do
assert_difference('article.count') do assert_difference('Article.count') do
post :create, article: {title: 'Hi', body: 'This is my first article.'} post :create, article: {title: 'Hi', body: 'This is my first article.'}
end end
assert_redirected_to article_path(assigns(:article)) assert_redirected_to article_path(assigns(:article))