However,
test/unit/whats_new_test.rb
-----------------
whats_news(:data1)
-----------------
=> "No class attached to find."
-----------------------------------------------
class Fixtures
...
def initialize
...
@class_name = class_name ||
(ActiveRecord::Base.pluralize_table_names ?
@table_name.singularize.camelize : @table_name.camelize)
p @class_name
...
end
-----------------------------------------------
=> "WhatsNews"
A true class name is "WhatsNew".
@table_name == "whats_news"
"whats_news".singularize.camelize
=> "WhatsNews"
"whats_new".pluralize.singularize
=> "whats_news"
By the way, I cannot speak English...
In english, 'news' is both singular and plural. A single news item is still called 'news' not 'new'.
Two choices for you..
- Add your own inflection so that 'news' is singularlized to 'news'.
- Change your class name.
- Add your own inflection so that 'news' is singularlized to 'news'.
- Change your class name.
Keep in mind that model names should be nouns. Controller actions are
verbs. In your case of WhatsNew is practically a complete sentence.
"What is new?" Maybe use something like NewsItem or simply News, which
rails will properly pluralize as "News." In this case the table name
will be news.
Then to find out, "What is new?" you can create a named_scope that gets
recent new items like this: