将文件夹添加到app rails 4

时间:2013-10-15 05:09:28

标签: ruby-on-rails ruby-on-rails-4

如何将文件夹添加到rails app目录中。 在我的config / require.rb

Dir[File.join(Rails.root, "app/models", "extract_form_objects", "*.rb")].each {|l| require l }

但是当我启动rails项目rails s时,我有错误:

/home/sergey/rubystack_2.0.0-5/ruby/lib/ruby/gems/2.0.0/gems/virtus-0.5.5/lib/virtus/class_methods.rb:67:in `const_missing': uninitialized constant ChannelTemplateEventPost::ActivModel (NameError)

这是app / models / extract_form_objects中的类rb文件

class ChannelTemplateEventPost

  include Virtus
  extend ActivModel::Naming
  include ActiveModel::Conversion
  include ActiveModel::Validations

  attr_reader :user_posts
  attr_reader :events

  attribute :channel_id, Integer
  attribute :current_user_id, Integer
  attribute :post_id, Array



  def save
    persist!
  end

  private
    def persist!
      @event = Event.creata!(event_post_list: post_id, user_id: current_user_id,urrent_user_id: current_user_id)
    end
end

1 个答案:

答案 0 :(得分:1)

正如那些家伙已经提到的那样你有一个错字。 Plus Rails希望您按文件夹命名这些对象,因此它将是:

class ExtractFormObjects::ChannelTemplateEventPost