gpt4 book ai didi

ruby-on-rails - 如何使用 Opal 生成示例 Rails 应用程序?

转载 作者:太空宇宙 更新时间:2023-11-03 16:01:22 24 4
gpt4 key购买 nike

我正在按照 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

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

最佳答案

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

据我所知,opal-rails 实际上不提供任何 Assets 生成器。按照 Rails 惯例,在 opal-rails/lib/rails/generators/opal/assets 处或附近应该有一个 assets_generator.rb 文件,但在源代码。

您可以自己将 Assets 生成器添加到项目中(请参阅 https://github.com/rails/coffee-rails/blob/master/lib/rails/generators/coffee/assets/assets_generator.rb 和相关文件以了解 Assets 生成器的外观示例)。

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

关于ruby-on-rails - 如何使用 Opal 生成示例 Rails 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24210970/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com