Ruby on Rails Inflection Issue

前端 未结 2 1811
再見小時候
再見小時候 2021-01-19 21:59

I am using Ruby on Rails to create a website for a game I play.

I have a User model and a Starbase model. The relationship I am trying to

相关标签:
2条回答
  • 2021-01-19 22:40

    Little trick i picked up to double check how Active Support might singularize, or pluralize my Class names, and/or Module names.

    have your rails app server running and in a new tab enter into your rails console by typing rails console. In there you can easily double check for the correct style for your names.

    long way ActiveSupport::Inflector.pluralize "fish" # => "fish"

    short way "fish".pluralize # => "fish"

    You can find more examples here

    https://github.com/rails/rails/blob/master/activesupport/test/inflector_test_cases.rb

    0 讨论(0)
  • 2021-01-19 22:44

    Have you tried adding a line for the inverse inflection (i.e. 'singular'):

     inflect.singular "starbases", "starbase"
    

    I tried your example in my console and it was the singularization that caused problems, not the other way around. I'm not sure if this fixes other issues (like routes), but it should fix the simple stuff (I think).

    0 讨论(0)
提交回复
热议问题