undefined局部变量或方法`has_no_table'

时间:2013-11-16 02:19:33

标签: ruby-on-rails database google-drive-api

这是我的'note'模型:

class Note < ActiveRecord::Base
    has_no_table
    column :title, :string
    column :contents, :string
    def update_spreadsheet
        connection = GoogleDrive.login(ENV["GMAIL_USERNAME"], ENV["GMAIL_PASSWORD"])
        ss = connection.spreadsheet_by_title('central-app-notes')
        if ss.nil?
        ss = connection.create_spreadsheet('central-app-notes')
        end
        ws = ss.worksheets[0]
    last_row = 1 + ws.num_rows
    ws[last_row, 1] = Time.new
    ws[last_row, 2] = self.title
    ws[last_row, 3] = self.content
    ws.save
    end
end

我还添加了“google_drive”gem。

但是,当我尝试使用表单访问页面时,出现此错误:

undefined local variable or method `has_no_table' 

我不确定发生了什么,并希望得到一些帮助。谢谢!

1 个答案:

答案 0 :(得分:2)

方法has_no_table来自activerecord-tableless gem

所以请在你的Gemfile中加入

gem "activerecord-tableless", "~> 1.0"

捆绑并重启服务器,希望有帮助

另请查看activerecord-tableless gem以获取更多信息