鞋子设置问题

时间:2013-06-18 09:55:50

标签: ruby shoes

当我运行shoes.rb文件时,它包含安装gem的代码,它会抛出错误。

  

鞋子的未定义方法设置:类

代码:

Shoes.setup do
  gem 'activerecord' # install AR if not found

  require 'active_record'
  require 'fileutils'

  ActiveRecord::Base.establish_connection(
    :adapter   => 'postgresql',
    :dbfile    => 'shoes_app'
  )

  # create the db if not found
  unless File.exist?("shoes_app.sqlite3")
    ActiveRecord::Schema.define do
      create_table :notes do |t|
        t.column :message, :string
      end
    end
  end

end

class ShoesApp < Shoes
  require 'note'

  url '/', :index

  def index
    para 'Say something...'
    flow do
      @note = edit_line
      button 'OK' do
        Note.new(:message => @note.text).save
        @note.text = ''
        @result.replace get_notes  
      end
    end
    @result = para get_notes
  end

  def get_notes
    messages = []
    notes = Note.find(:all, :select => 'message')
    notes.each do |foo|
      messages << foo.message
    end
    out = messages.join("n")
  end

end

Shoes.app :title => 'Notes', :width => 260, :height => 350

1 个答案:

答案 0 :(得分:0)

问题在于使用了Shoes4,其中安装方法未实现。

Shoes4现在为了向后兼容性而实现了Shoes.setup,但你真的不需要它,所以除了打印一个你应该做gem install gem_name而不是使用Shoes.setup的警告之外它什么都不做