Fix debugging rails application [ci skip]
This commit is contained in:
parent
691af78900
commit
b44b393243
|
@ -162,20 +162,24 @@ class ArticlesController < ApplicationController
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@article = Article.new(params[:article])
|
@article = Article.new(article_params)
|
||||||
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.'
|
|
||||||
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, notice: 'Article was successfully created.'
|
||||||
else
|
else
|
||||||
render action: "new"
|
render :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
|
private
|
||||||
|
def article_params
|
||||||
|
params.require(:article).permit(:title, :body, :published)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -542,7 +546,7 @@ command later in this guide).
|
||||||
9
|
9
|
||||||
=> 10 respond_to do |format|
|
=> 10 respond_to do |format|
|
||||||
11 format.html # index.html.erb
|
11 format.html # index.html.erb
|
||||||
12 format.json { render json: @articles }
|
12 format.json { render json: @articles }
|
||||||
13 end
|
13 end
|
||||||
14 end
|
14 end
|
||||||
15
|
15
|
||||||
|
|
Loading…
Reference in New Issue