Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7715403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:22:34+00:00 2026-06-01T02:22:34+00:00

When I go to the path: /genre/new in my application I get this error:

  • 0

When I go to the path: /genre/new in my application I get this error:

myapp/app/views/genre/_form.html.erb where line #1 raised:
undefined method `genres_path' for #<#<Class:0x007fdcb39edcb0>:0x007fdcb39e8080>

However when I go to /genre/:id/edit the _form.html.erb file renders without error and the record is updated with no problems.

My new.html.erb and edit.html.erb files call <%= render 'form' %> and my _form.html.erb file has:

<%= form_for(@genre) do |f| %>
    <%= f.label :title %> <br />  <%= f.text_field :title %>
    <%= f.label :desc %>  <br />  <%= f.text_field :desc %>
    <%= f.submit %>
<% end %>

In genre_controller.rb my ‘new’ and ‘edit’ actions are as follows:

  def new
    @genre = Genre.new
    current_user.authorize! :create, @genre  # cancan authorization

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @genre }
    end
  end

  def edit
    @genre = Genre.find(params[:id])
    current_user.authorize! :update, @genre   # cancan authorization
  end

I’ve run a search in my codebase for the string “genres” and the only place it occurs is in the logs, so I’m sure this is not a typo in my code.

My guess is that Rails routing system correctly pluralizes “genre” to “genre”, but form_for (or a dependency) is creating the pluralization “genres”, but only when the parameter passed to it is empty or “new”.

Given the error is around ‘genres_path’, I tried various combinations of the following in my routes.rb file, but they didn’t solve the problem:

  match "/genres" => "genre#index", :as => :genre
  match "/genres/:id(.:format)" => "genre#show", :as => :genre
  match "/genre" => "genre#index", :as => :genres
  match "/genre/:id(.:format)" => "genre#show", :as => :genres

Any thoughts on how I can work around this?

EDIT: Here are the routes generated by the resources :genre statement in my routes.rb file:

genre_index GET    /genre(.:format)           {:action=>"index", :controller=>"genre"}
            POST   /genre(.:format)           {:action=>"create", :controller=>"genre"}
  new_genre GET    /genre/new(.:format)       {:action=>"new", :controller=>"genre"}
 edit_genre GET    /genre/:id/edit(.:format)  {:action=>"edit", :controller=>"genre"}
      genre GET    /genre/:id(.:format)       {:action=>"show", :controller=>"genre"}
            PUT    /genre/:id(.:format)       {:action=>"update", :controller=>"genre"}
            DELETE /genre/:id(.:format)       {:action=>"destroy", :controller=>"genre"}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:22:36+00:00Added an answer on June 1, 2026 at 2:22 am

    on new.html.erb try

    <%= form_for(@genre, :url => genre_path, :method => :post) do |f| %>
    

    assuming you have your route setup as a resource – resources :genre

    also this will not work on edit.html.erb

    http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_for

    Update:

    this is the one we are interested in

    POST   /genre(.:format)           {:action=>"create", :controller=>"genre"}
    

    try this

    <%= form_for(@genre, :url => {:action=>"create", :controller=>"genre"}, :method => :post) do |f| %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error: ArgumentError in Videos#index Showing /rubyprograms/dreamstill/app/views/layouts/application.html.erb where line #15 raised: No
When i run my features i get this error: undefined method `visit' for #<Cucumber::Rails::World:0x81b17ac0>
How to get the path of the current csproject? Let's say I have a
I have my path to the MySQLdb source folder I downloaded using apt-get install
Possible Duplicate: Absolute path & Relative Path This is a very basic question, but
In the Path iphone application, on the bottom left corner, there is a +
I have this Html Helper public static MvcHtmlString EditButton(this HtmlHelper html, string action, string
complete HTML virgin 3 weeks ago but have managed to stumble along and get
If I try the getting-started on http://flexmojos.sonatype.org/getting-started.html I get some errors. Can somebody help
os.path.getmtime() and os.stat() seem to return values in whole seconds only. Is this the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.