Topic: Rails - NameError and incorrect routing done by form_for method

I am creating an application and this is the error I am getting after running the application

NameError in Offers#index

Showing /home/fash/projs/rnh/app/views/offers/index.html.erb where line #19 raised:

undefined local variable or method `new_offers_path' for #<#<Class:0x95806c0>:0x9c51b5c>
Extracted source (around line #19):

16:   <% end %>
17: </table>
19: <p><%= link_to "New Offers", new_offers_path %></p>
Rails.root: /home/fash/projs/rnh

the routes file

Rnh::Application.routes.draw do
  resources :offers do
    resource :details
    resources :photos

the offers_controller file

class OffersController < ApplicationController
  def index
    @offers = Offers.all

  def show
    @offers = Offers.find(params[:id])

  def new
    @offers =

  def create
    @offers =[:offers])
      redirect_to @offers, :notice => "Successfully created offers."
      render :action => 'new'

  def edit
    @offers = Offers.find(params[:id])

  def update
    @offers = Offers.find(params[:id])
    if @offers.update_attributes(params[:offers])
      redirect_to @offers, :notice  => "Successfully updated offers."
      render :action => 'edit'

  def destroy
    @offers = Offers.find(params[:id])
    redirect_to offers_url, :notice => "Successfully destroyed offers."

the index.html.erb file:

<% title "Offers" %>

  <% for offers in @offers %>
      <td><%= offers.u_id %></td>
      <td><%= offers.available %></td>
      <td><%= link_to "Show", offers %></td>
      <td><%= link_to "Edit", edit_offers_path(offers) %></td>
      <td><%= link_to "Destroy", offers, :confirm => 'Are you sure?', :method => :delete %></td>
  <% end %>

<p><%= link_to "New Offers", new_offers_path %></p>

I am new to rails and am not getting what can be the problem? is it the naming convention ? or something else? If anything else is needed please do post I need to sort the problem soon

Re: Rails - NameError and incorrect routing done by form_for method

Nothing wrong with your code as far as I can see.
Reboot your PC and try again. Maybe something is messing with your development environment and preventing your server from using your latest code. A reboot is a bit of overkill, normally just restarting your webserver should be enough but in this case I would suggest there is something more fundamentally wrong with your environment

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Rails - NameError and incorrect routing done by form_for method

the error was with pluralization of the model, so i renamed it as offer rather than offers