开发者

rails g scaffold series name:string - is this a naming convention error or something else

On my blog I'm have posts that belong to a series. I've开发者_运维技巧 tried to scaffold series but there are some problems with routes.

The pluralization engine doesn't get it right so I had to manually change Sery, @series, and @sery which is not a big deal.

The routing seems to be ok with resources :series. But then when I try to create a series the form_for helper complains about the route.

And then when I create it with console it works but rails is still complaining about routes.

Please create a simple app and see what the problem is.

rails new test_series_app

And then run the scaffold generator:

rails g scaffold series name:string

And see how the routes are getting mixed up and help me out please!


For the record, I put the singularize code into the scaffold generator (yes, my one contribution to Rails). All it does is check if record_name == record_name.pluralize. If it does and you haven't passed in --force-plural, it calls record_name = record_name.singularize.

In this case "series".pluralize is the same as "series".singularize so I assume it won't do anything.

So if you're having problems w/ it, you need to write an inflector for the word.

(I wrote it after Jeremy Kemper's 2008 RailsConf keynote in which he accidentally passed in a plural model name causing himself all sorts of grief in the middle of his talk.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜