How to add folder in to rails app directory. in my config/require.rb
Dir[File.join(Rails.root, "app/models", "extract_form_objects", "*.rb")].each {|l| require l }
but when i start rails project rails s
i have error:
/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)
this is my class rb file in app/models/extract_form_objects
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
As the guys already mentioned You have a typo. Plus Rails will expect You to namespace those objects by folder, so it will be:
class ExtractFormObjects::ChannelTemplateEventPost
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.