ruby on rails - RSpec failure: undefined method `name' for nil:NilClass -
I am walking through a book (Action V14 map in railway 4) and an error in running my imagination Failures: 1) Creating projects can create a project failure / error: click_button 'Create Project' ActionView :: Template :: Error: The undefined method for 'zero' Name ': NilClass # ./app/ Ideas / Project / show.html.erb: 1: In `_app_views_projects_show_html_erb__1338549725163946383_70209940313300' # ./spec/features/creating_projects_spec.rb11:in 'Block ( 2 level) & lt; Top (required) & gt; '1 example ended in 0.23155 seconds, failure 1 failed Example: rspec ./spec/features/creating_projects_spec.rb:4 # Creating projects can create a project
I am online and through Finding the book and instructions have been followed. I can not find my fault book (where I am currently on page 91) says that I should get the following error instead:
Failure / Error: Hope (page) Has'content ('Project Is Created') is expected to text "Project has been created." My repository for the project
Any guidance is highly appreciated.
In your controller's show method you have the example variable @projects Set (plural) def show @projects = project.find (params [: id]) end in Show You see the frequency variable using the @ project (singular). & lt; H2 & gt; & lt;% = @ project.name% & gt; & Lt; / H2 & gt; As a result of this, there are no example variables @project , so when attempting to call the view name method Actually doing zero.name , hence the undefined method error. Change your controller method:
def show @project = Project.find (params [: id]) @project instead of @projects
Comments
Post a Comment