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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eb6042d3fdf039e9259b1a5f17db337c?d=identicon&s=25 The Ultimation (pimeamark)
on 2009-01-14 19: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
with:

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 = News.new. 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"
end

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.