2014-09-19 5 views
0

나는 'RSVP'라는 모델과 컨트롤러에 스캐 폴드 제너레이터를 사용하려고합니다. 굴절을 정의하면 rsvps_controller.rb에 RSVPController 클래스가 있고 RSVP 모델에는 RSVPs 테이블이있는 것이 좋습니다. 나는 또한 RsvpController와 Rsvp를 받아 들일 만하다.레일 약어 약어의 중간 분할 약어

불행히도 'RSV P'에 'RSVP'가 나뉘어져있는 것 같습니다. 따라서 rails generate scaffold RSVP ...은 rsv_ps_controller, RsvPsController 및 rSVPs를 비롯한 다양한 맞춤법의 배열을 만들었습니다. 허용되는 유일한 결과는 Rsvp 클래스가있는 rsvp.rb라는 모델 파일입니다.

원하는 결과를 얻으려면 적절한 방법이 있습니까? 나는 레일을 사용하고 4.1.4

내 설정은/이니셜/inflections.rb은 다음과 같습니다. 나는 사람들의 모든 조합을 시도했습니다

ActiveSupport::Inflector.inflections(:en) do |inflect| 
    inflect.acronym 'RSVP' 
    inflect.irregular 'RSVP', 'RSVPs' 
end 

이 (즉, 모두 개별적으로뿐만 아니라 모두 정의는). 둘 다 같은 결과를 얻는 것 같습니다.

> bundle exec rails generate scaffold RSVP account:references ... 
     invoke active_record 
     create db/migrate/20140918213359_create_rSVPs.rb 
     create app/models/rsvp.rb 
     invoke test_unit 
     create  test/models/rsvp_test.rb 
     create  test/fixtures/rSVPs.yml 
     invoke resource_route 
     route resources :rSVPs 
     invoke scaffold_controller 
     create app/controllers/rsv_ps_controller.rb 
     invoke erb 
     create  app/views/rsv_ps 
     create  app/views/rsv_ps/index.html.erb 
     create  app/views/rsv_ps/edit.html.erb 
     create  app/views/rsv_ps/show.html.erb 
     create  app/views/rsv_ps/new.html.erb 
     create  app/views/rsv_ps/_form.html.erb 
     invoke test_unit 
     create  test/controllers/rsv_ps_controller_test.rb 
     invoke helper 
     create  app/helpers/rsv_ps_helper.rb 
     invoke  test_unit 
     create  test/helpers/rsv_ps_helper_test.rb 
     invoke jbuilder 
     create  app/views/rsv_ps/index.json.jbuilder 
     create  app/views/rsv_ps/show.json.jbuilder 
     invoke assets 
     invoke coffee 
     create  app/assets/javascripts/rsv_ps.js.coffee 
     invoke scss 
     create  app/assets/stylesheets/rsv_ps.css.scss 
     invoke scss 
     create app/assets/stylesheets/scaffolds.css.scss 
+0

당신은 ... 대신 RSVP''의'Response' 나는 것을 고려하고 – nort

+0

를 호출 할 수 있지만 나는을 할 수 있어야한다 생각 다음 문서에서

ActiveSupport::Inflector.inflections(:en) do |inflect| inflect.acronym 'RSVP' inflect.acronym 'RSVPs' end 

이 같은 약어는 모델 이름입니다. – dsample

답변

0

ActiveSupport::Inflector::Inflections.acronym 방법에 대한 문서는 모두 단수와 복수로 형태의 약자 항목을 추가해야 함을 나타냅니다.

다음은 작동해야 함을 의미합니다. 그러나, 이것은 여전히 ​​나를 위해 작동하지 않습니다.

# Note: Acronyms that are passed to +pluralize+ will no longer be 
    # recognized, since the acronym will not occur as a delimited unit in the 
    # pluralized result. To work around this, you must specify the pluralized 
    # form as an acronym as well: 
    # 
    # acronym 'API' 
    # camelize(pluralize('api')) # => 'Apis' 
    # 
    # acronym 'APIs' 
    # camelize(pluralize('api')) # => 'APIs'