0
votes

I have tried everything, so now I'm asking for help.

NoMethodError in Jobs#index Showing /Users/sillaspoulsen/Desktop/Coderstravel/app/views/jobs/index.html.erb where line #15 raised:

undefined method `each' for nil:NilClass

" <% @jobs.each do |job| %> "

Here is my git if that helps: https://github.com/SillasPoulsen/coders

Thank you so much.

1

1 Answers

3
votes

In JobsController, change

  def index
    @job = Job.all
  end

To

  def index
    @jobs = Job.all  ## plural jobs
  end

You are setting the instance variable as @job in index action and using @jobs (Notice plural) in index.html.erb which obviously would be nil. So, you get the error as undefined method 'each' for nil:NilClass

UPDATE

it gives me the error NoMethodError in Jobs#index- " undefined method `description' for #" "<%= job.description %>"

jobs table has a field named discription and you are accessing description which does not exist in jobs table. Hence, the error.