On 11/5/05, CSN
<cool_screen_name90001-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
wrote:> I''m new to Rails (coming from years of PHP) and am
> pretty excited about it. However, what''s the logic of
> singularization (inflection?)? e.g. items becomes Item
> with controllers, models, etc. I have to say I don''t
> think I like it as it seems to confuse and get in the
> way (I have URL''s like items/category/page and
> item/id). But perhaps I''ll change my mind if I know
> the reasons behind it. I''ve read quite a few of the
> docs and haven''t seen anything that explains the why.
>
> Thanks,
> CSN
10 Reasons Rails Does Pluralization
http://weblog.rubyonrails.com/archives/2005/08/25/10-reasons-rails-does-pluralization
Really, it comes down to one thing: it was the way it was written. It
looks natural to write code like this:
class Post < ActiveRecord::Base
has_many :comments
belongs_to :author
end
@posts = Post.find :all
@post = Post.find 1
@post.comments << @comment
Most words are handled well, but you you have three options should the
problem arise:
1) Add new inflection rules
(example in your environment.rb
http://dev.rubyonrails.com/browser/trunk/railties/environments/environment.rb#L42)
2) Override that model''s table name
class Post < ActiveRecord::Base
set_table_name ''post''
end
3) turn off pluralization altogether:
# in environment.rb
config.active_record.pluralize_table_names = false
--
rick
http://techno-weenie.net