未定义的方法'dragonfly_accessor' [英] undefined method 'dragonfly_accessor'

查看:72
本文介绍了未定义的方法'dragonfly_accessor'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是蜻蜓的新手,正在尝试按照Rails的主要文档页面上的设置说明进行操作.不使用Active Record.

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

我的步骤:

1)添加到Gemfile

1) add to Gemfile

gem 'dragonfly', "~>1.0.3"

2)bundle install

3)rails g dragonfly

创建了初始值设定项/dragonfly.rb

created initializers/dragonfly.rb

4)模型

class Post

  include Mongoid::Document

  dragonfly_accessor :image

  field :title, type: String

  field :body, type: String

end

5)控制器

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

仅运行mongod和rails,我得到未定义方法'dragonfly_accessor'的错误

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

有什么想法我想念的吗?

Any ideas what I am missing?

推荐答案

此外,用户的错误是他没有从ActiveRecord :: Base继承. 文档在这里. ( https://github.com/markevans/dragonfly )

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

这篇关于未定义的方法'dragonfly_accessor'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆