Я новичок с рельсов и, начиная с http://guides.rubyonrails.org/getting_started.html stucked в 5.7 Showing Articles
с следующей ошибкой:NoMethodError неопределенный метод ` 'для ноль: NilClass
NoMethodError in Articles#show
Showing /home/jakub/workspace/blog/blog/app/views/articles/show.erb where line #3 raised:
undefined method `title' for nil:NilClass
Где источник:
<p>
<strong>Title:</strong>
<%= @article.title %>
</p>
<p>
articles_controller.rb
и является:
class ArticlesController < ApplicationController
def index
@articles = Article.all
end
def create
@article = Article.new(article_params)
@article.save
redirect_to @article
end
private
def article_params
params.require(:article).permit(:title, :text)
end
def show
@article = Article.find(params[:id])
end
end
и rake routes
команда приносит:
Prefix Verb URI Pattern Controller#Action
welcome_contact GET /welcome/contact(.:format) welcome#contact
welcome_index GET /welcome/index(.:format) welcome#index
articles GET /articles(.:format) articles#index
POST /articles(.:format) articles#create
new_article GET /articles/new(.:format) articles#new
edit_article GET /articles/:id/edit(.:format) articles#edit
article GET /articles/:id(.:format) articles#show
PATCH /articles/:id(.:format) articles#update
PUT /articles/:id(.:format) articles#update
DELETE /articles/:id(.:format) articles#destroy
root GET / welcome#index
Любая идея, что может вызвать эту проблему? Где я должен искать?
... такая ловушка в «начале» :) – Jacob