Follow-up to #15215 [ci skip]
This commit is contained in:
parent
2053e1f8da
commit
11ac0cad08
|
@ -159,10 +159,10 @@ class ArticlesController < ApplicationController
|
|||
def create
|
||||
@article = Article.new(params[:article])
|
||||
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
|
||||
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..."
|
||||
redirect_to(@article)
|
||||
else
|
||||
|
@ -184,7 +184,8 @@ vbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA=--b18cd92fba90eacf8137e
|
|||
"body"=>"I'm learning how to print in logs!!!", "published"=>"0"},
|
||||
"authenticity_token"=>"2059c1286e93402e389127b1153204e0d1e275dd", "action"=>"create", "controller"=>"articles"}
|
||||
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",
|
||||
"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')
|
||||
|
|
|
@ -394,7 +394,7 @@ end
|
|||
```
|
||||
|
||||
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:
|
||||
`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
|
||||
`:class_name` option here.
|
||||
|
||||
Next, there needs to be a form so that comments can be created on a article. To add
|
||||
this, put this line underneath the call to `render @article.comments` in
|
||||
Next, there needs to be a form so that comments can be created on an article. To
|
||||
add this, put this line underneath the call to `render @article.comments` in
|
||||
`app/views/blorgh/articles/show.html.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.
|
||||
|
||||
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
|
||||
calls this class something different, such as `Person`. For this reason, the
|
||||
engine should not hardcode associations specifically for a `User` class.
|
||||
authors for an article or a comment. But there could be a case where the
|
||||
application calls this class something different, such as `Person`. For this
|
||||
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`
|
||||
that represents the users of the application. It can be generated using this
|
||||
|
|
|
@ -585,7 +585,7 @@ Here's another example that uses `flash`, `assert_redirected_to`, and `assert_di
|
|||
|
||||
```ruby
|
||||
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.'}
|
||||
end
|
||||
assert_redirected_to article_path(assigns(:article))
|
||||
|
|
Loading…
Reference in New Issue