0

gem をインストールするためのコードを含む shoes.rb ファイルを実行すると、エラーがスローされます。

Shoes:Class の未定義メソッド設定

コード:

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
4

1 に答える 1

0

問題は、セットアップ方法が実装されていないShoes4を使用していたことです。

Shoes4 は現在、下位互換性のために Shoes.setup を実装していますが、実際には必要ないため、gem install gem_nameShoes.setup を使用する代わりに実行する必要がある警告を表示する以外には何もしません。

于 2013-07-02T21:40:21.070 に答える