undefined method 'dragonfly_accessor'

2019-04-10 18:26发布

问题:

I am new to dragonfly and trying to go through the setup directions on the main documentation page for rails. Not using Active Record.

My steps:

1) add to Gemfile

gem 'dragonfly', "~>1.0.3"

2) bundle install

3) rails g dragonfly

created initializers/dragonfly.rb

4) model

class Post

  include Mongoid::Document

  dragonfly_accessor :image

  field :title, type: String

  field :body, type: String

end

5) controller

params.require(:post).permit(:title, :body, :image)

Just running mongod and rails s, I get the error of undefined method 'dragonfly_accessor'

Any ideas what I am missing?

回答1:

Also, the user’s error is that he’s not inheriting from ActiveRecord::Base. Documentation is here. (https://github.com/markevans/dragonfly)