2

我正在遵循http://opalrb.org/docs/rails/上的指南。第一步顺利:

rails new MyHappyApp --javascript=opal

但是当我尝试实际生成一个脚手架时......

rails g scaffold Persion name age:int
/home/jared/.rvm/gems/ruby-2.1.1@rails32/gems/opal-sprockets-0.0.1/lib/opal/sprockets/server.rb:81: warning: already initialized constant Opal::Server::Index::SOURCE
/home/jared/.rvm/gems/ruby-2.1.1@rails32/gems/opal-0.3.44/lib/opal/server.rb:90: warning: previous definition of SOURCE was here
    SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
    This poses a security threat. It is strongly recommended that you
    provide a secret to prevent exploits that may be possible from crafted
    cookies. This will not be supported in future versions of Rack, and
    future versions will even invalidate your existing user cookies.

    Called from: /home/jared/.rvm/gems/ruby-2.1.1@rails32/gems/actionpack-3.2.0/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'.
  invoke  active_record
  create    db/migrate/20140613172929_create_persions.rb
  create    app/models/persion.rb
  invoke    test_unit
  create      test/unit/persion_test.rb
  create      test/fixtures/persions.yml
   route  resources :persions
  invoke  scaffold_controller
  create    app/controllers/persions_controller.rb
  invoke    erb
  create      app/views/persions
  create      app/views/persions/index.html.erb
  create      app/views/persions/edit.html.erb
  create      app/views/persions/show.html.erb
  create      app/views/persions/new.html.erb
  create      app/views/persions/_form.html.erb
  invoke    test_unit
  create      test/functional/persions_controller_test.rb
  invoke    helper
  create      app/helpers/persions_helper.rb
  invoke      test_unit
  create        test/unit/helpers/persions_helper_test.rb
  invoke  assets
   error    opal [not found]
  invoke    scss
  create      app/assets/stylesheets/persions.css.scss
  invoke  scss
  create    app/assets/stylesheets/scaffolds.css.scss

有谁知道为什么我会收到“错误蛋白石 [未找到]”行?

4

1 回答 1

2

我刚刚对此进行了测试,并且能够复制该错误。

据我所知,opal-rails实际上并没有提供任何资产生成器。assets_generator.rb按照 Rails 约定,在 或周围应该有一个文件opal-rails/lib/rails/generators/opal/assets,但源代码中没有这样的文件。

您可以自己将资产生成器添加到项目中(参见https://github.com/rails/coffee-rails/blob/master/lib/rails/generators/coffee/assets/assets_generator.rb和相关文件的示例资产生成器的样子)。

另一种选择是config.app_generators.javascript_engine = :js在你的application.rb文件中设置,然后适当地重命名它(例如,to persons.js.rb)。

于 2014-06-16T14:23:22.987 回答