【问题标题】:How to create a namespaced model instance in Rails 3如何在 Rails 3 中创建命名空间模型实例
【发布时间】:2013-12-08 19:11:35
【问题描述】:

我有这个模型:

class Backend::Enterprise < ::Enterprise  

如何在其命名空间中调用和实例化此模型?

如果我写,backend_enterprises_controller:

@enterprise = Enterprise.find(1)

它调用模型:

class Enterprise < ActiveRecord::Base

我想在每个命名空间模型中使用单独的方法。

有可能吗?我正在使用 Rails 3.2.14 和inherited_resources gem。

谢谢。

【问题讨论】:

    标签: ruby-on-rails ruby inherited-resources


    【解决方案1】:

    也许我误解了你的问题,但你试过了吗

    @enterprise = Backend::Enterprise.find(1)
    

    ?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-10
      • 2012-04-18
      • 2017-03-21
      • 2017-03-25
      • 1970-01-01
      • 2013-12-14
      • 2011-09-27
      • 2011-05-23
      相关资源
      最近更新 更多