【问题标题】:Concern and field Rails关注和现场 Rails
【发布时间】:2014-02-20 11:39:48
【问题描述】:

我想创建一个这样的问题:

module Geolocalizable
  extend ActiveSupport::Concern
  include Mongoid

  included do
    attr_accessible :lat, :lng
    field :lat
    field :lng
  end
end

然后将其包含在我的模型中:

class Store
   include Mongoid::Document
   include 'Geolocalizable'

   field :name, type: String
   field :address, type: String
end

但在我的商店/new.html.erb 这一行给了我一个错误

f.text_filed :lat 

#Store:0xae6bb58 的未定义方法“lat”

我该如何解决这个问题?

【问题讨论】:

    标签: ruby-on-rails actionview activesupport-concern


    【解决方案1】:

    我认为是参数类型错误,应该是:include Geolocalizable

    【讨论】:

    • 谢谢!我真的很糟糕:/
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多