【问题标题】:Issue with Shoes setup鞋子设置问题
【发布时间】:2013-06-18 09:55:50
【问题描述】:

当我运行包含安装 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

【问题讨论】:

标签: ruby shoes


【解决方案1】:

问题在于使用 Shoes4,设置方法未实现。

出于向后兼容性的原因,Shoes4 现在实现了 Shoes.setup,但您并不真正需要它,因此它除了打印警告说您应该执行 gem install gem_name 而不是使用 Shoes.setup。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-13
    • 2013-02-24
    • 2010-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多