Forum: Ruby on Rails Edit method problem with a plural-named model

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
The U. (Guest)
on 2009-01-14 20:24
Hi, I recently made a model called 'news'. I realize that it's plural
and was gonna cause some problems, but I got the routing all down fine

map.resources :news, :singular => :news_article

everything works fine except the EDIT method. it gives me this error:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.to_sym

Extracted source (around line #2):

1: <%= error_messages_for :news %>
2: <% form_for @news do |f| %>

@news is defined in the controller like standard in an edit method:

@news = News.find(params[:id])

The @news retrieves the data correctly, I've tested it, so the problem
is with <%form_for @news do |f|%>. What's wierd is my create method
works just fine with
@news = But when I give @news a value, it won't work. I just
want to know how to make edit work with a plural model like this. I've
searched extensively and can't seem to find out.

P.S. I saw someone reccomend doing

ActiveSupport::Inflector.inflections do |inflect|
 inflect.uncountable "news"

in the inflector file but it didn't work for me. I assume you need to
have that there before you create the model, which I didn't. Any help
would be greatly appreciated!
This topic is locked and can not be replied to.