NoMethodError in
Posts#show Hello,
I’m new at Ruby on Rails, I’m using : -Ubuntu 14.04 LTS -Rails 4.1.2 -Ruby 2.1.2p95 -rvm 1.25.27
I’m actually following the rails guides : http://guides.rubyonrails.org/v4.0.6/getting_started.html#getting-up-and-running Everything was going well until the point : 5.7 Showing points. I have checked my files several times and I can’t figure out where is my mistake, I can submit a post and then there is no display I get the error :
Showing /home/jeremy/projet/blog/app/views/posts/show.html.erb where line #3 raised:
undefined method `title' for nil:NilClass
Extracted source (around line #3):
1
2
3
4
5
6
<p>
<strong>Title:</strong>
<%= @post.title %>
</p>
<p>
Following you'll find my files :
-config/routes.rb
Rails.application.routes.draw do
get 'welcome/index'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
resources :posts
# You can have the root of your site routed with "root"
root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end