首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >超级堆栈找不到登陆页面资源

超级堆栈找不到登陆页面资源
EN

Stack Overflow用户
提问于 2019-06-24 00:31:19
回答 1查看 2.2K关注 0票数 1

超文本/install指南向您展示了如何向现有的Rails应用程序添加超文本。我已经到了能够像以前一样启动遗留应用程序的地步,但是图像资源的路径无法解决。我认为我只是没有得到正确的路线设置,另一方面,我没有改变什么,从指南上说。这是超级堆栈的第一关,感觉很明显,但它并没有屈服于我已经尝试过的简单测试。

代码语言:javascript
复制
routes.rb

    Rails.application.routes.draw do

    mount Hyperstack::Engine => '/hyperstack'  # this route should be first in the routes file so it always matches

/超级堆栈/超级组件.

代码语言:javascript
复制
# app/hyperstack/hyper_component.rb
class HyperComponent
  # All component classes must include Hyperstack::Component
  include Hyperstack::Component
  # The Observable module adds state handling
  include Hyperstack::State::Observable
  # The following turns on the new style param accessor
  # i.e. param :foo is accessed by the foo method
  param_accessor_style :accessors
end

/组件/发运。

代码语言:javascript
复制
class Shipment < HyperComponent

  # param :my_param
  # param param_with_default: "default value"
  # param :param_with_default2, default: "default value" # alternative syntax
  # param :param_with_type, type: Hash
  # param :array_of_hashes, type: [Hash]
  # other :attributes  # collects all other params into a hash
  # fires :callback  # creates a callback param

  # access params using the param name
  # fire a callback using the callback name followed by a !

  # state is kept and read as normal instance variables
  # but when changing state prefix the statement with `mutate`
  # i.e. mutate @my_state = 12
  #      mutate @my_other_state[:bar] = 17

  # the following are the most common lifecycle call backs,
  # delete any that you are not using.
  # call backs may also reference an instance method i.e. before_mount :my_method

  before_mount do
    # any initialization particularly of state variables goes here.
    # this will execute on server (prerendering) and client.
  end

  after_mount do
    # any client only post rendering initialization goes here.
    # i.e. start timers, HTTP requests, and low level jquery operations etc.
  end

  before_update do
    # called whenever a component will be re-rerendered
  end

  before_unmount do
    # cleanup any thing before component is destroyed
    # note timers are broadcast receivers are cleaned up
    # automatically
  end

  render do
    DIV do
      'Shipment'
    end
  end
end

命令行从开始

代码语言:javascript
复制
$ bundle exec foreman start
...
ActionView::Template::Error (couldn't find file 'client_and_server-e8a2a4c02f7542e3e05c' with type 'application/javascript'
...

后来在命令行中,

代码语言:javascript
复制
/Users/john/.rvm/gems/ruby-2.6.2/gems/bootstrap-4.3.1/assets/stylesheets
16:45:00 web.1        |   /Users/john/.rvm/gems/ruby-2.6.2/gems/bootstrap-4.3.1/assets/javascripts):
16:45:00 web.1        |     10: 
16:45:00 web.1        |     11:  
16:45:00 web.1        |     12:   // search path default is public/images
16:45:00 web.1        |     13:   = image_tag "Drayage-LongBeach.jpg", :size => "520x360" 
16:45:00 web.1        |     14:   %p
16:45:00 web.1        |     15:   %p
16:45:00 web.1        |     16: 
EN

回答 1

Stack Overflow用户

发布于 2019-06-24 20:11:07

基于这个事实,它找不到您的打包清单文件(这是我之前假设的),我怀疑您在webpacker上< 4.0。

Webpacker现在将包存储在/javascripts/js中,而不仅仅是/javscripts/和超级堆栈安装程序。

保留Webpack的最新版本

进入config/initializers/assets.rb,您将看到最后一行,如下所示

代码语言:javascript
复制
Rails.application.config.assets.paths << Rails.root.join('public', 'packs', 'js').to_s

只要删除, 'js',它将与旧的webpacker一起工作。

config/environments/test.rb中也有一个类似的行,也需要修改才能使超规范工作。

升级Webpack (推荐-你迟早要做)

或者您可以将webpacker升级到~> 4.0。

对于这两种冲突,您都需要回答"Y“,如果存在,还必须删除.babelrc文件,并最终运行bin/webpack

  1. 更新您的Gemfile
  2. bundle install
  3. bundle exec rails webpacker:install对这两种冲突的回答Y
  4. 如果存在.babelrc,则删除它
  5. 运行bin/webpack

这将成功地将webpacker升级到4.x,现在一切都应该很好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56728653

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档