application.css 未作为资产提供

2024-05-10

编辑4、5和6

8小时后,欢迎任何更多的想法:)也许这个错误已经被知道并解决了,但是当你在 app/assets/stylesheets 的 .css.erb 文件中有这个时,我得到了我在编辑 2&3 中描述的行为:

li {
    background-image: url(<%= asset_path "logo_80px_80px.png" %>);
}

问题部分似乎是asset_path方法调用,但 .css.scss 也会破坏它:

li {
    background-image: url(image-path("logo_80px_80px.png"));
}

我的 GemFile 是:

source 'http://rubygems.org'

gem 'rails', '3.1.3'
gem 'pg', '0.11.0'
gem 'gravatar_image_tag', '1.0.0.pre2'
gem 'will_paginate'
gem 'rake'
gem 'jquery-rails'
gem 'nested_form'
gem 'acts-as-taggable-on'

gem 'sass-rails'
group :assets do
  gem 'coffee-rails', '~> 3.1.0'
  gem 'uglifier', '>= 1.0.3'
end

group :development do
  gem 'rspec-rails', '2.5.0'
  gem 'annotate', '2.4.0'
  gem 'faker', '0.3.1'
end


group :test do
  gem 'rspec', '2.5.0'
  gem 'webrat', '0.7.1'
  gem 'factory_girl_rails', '1.0'
end

group :production do
  gem 'therubyracer-heroku'
end

我的 Gemfile.lock 是:

GEM
  remote: http://rubygems.org/
  specs:
    actionmailer (3.1.3)
      actionpack (= 3.1.3)
      mail (~> 2.3.0)
    actionpack (3.1.3)
      activemodel (= 3.1.3)
      activesupport (= 3.1.3)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      i18n (~> 0.6)
      rack (~> 1.3.5)
      rack-cache (~> 1.1)
      rack-mount (~> 0.8.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.0.3)
    activemodel (3.1.3)
      activesupport (= 3.1.3)
      builder (~> 3.0.0)
      i18n (~> 0.6)
    activerecord (3.1.3)
      activemodel (= 3.1.3)
      activesupport (= 3.1.3)
      arel (~> 2.2.1)
      tzinfo (~> 0.3.29)
    activeresource (3.1.3)
      activemodel (= 3.1.3)
      activesupport (= 3.1.3)
    activesupport (3.1.3)
      multi_json (~> 1.0)
    acts-as-taggable-on (2.2.1)
      rails (~> 3.1)
    annotate (2.4.0)
    arel (2.2.1)
    builder (3.0.0)
    coffee-rails (3.1.1)
      coffee-script (>= 2.2.0)
      railties (~> 3.1.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.1.3)
    diff-lcs (1.1.3)
    erubis (2.7.0)
    execjs (1.2.12)
      multi_json (~> 1.0)
    factory_girl (1.3.3)
    factory_girl_rails (1.0)
      factory_girl (~> 1.3)
      rails (>= 3.0.0.beta4)
    faker (0.3.1)
    gravatar_image_tag (1.0.0.pre2)
    hike (1.2.1)
    i18n (0.6.0)
    jquery-rails (1.0.19)
      railties (~> 3.0)
      thor (~> 0.14)
    json (1.6.3)
    mail (2.3.0)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.17.2)
    multi_json (1.0.4)
    nested_form (0.1.1)
    nokogiri (1.5.0-x86-mingw32)
    pg (0.11.0-x86-mingw32)
    polyglot (0.3.3)
    rack (1.3.5)
    rack-cache (1.1)
      rack (>= 0.4)
    rack-mount (0.8.3)
      rack (>= 1.0.0)
    rack-ssl (1.3.2)
      rack
    rack-test (0.6.1)
      rack (>= 1.0)
    rails (3.1.3)
      actionmailer (= 3.1.3)
      actionpack (= 3.1.3)
      activerecord (= 3.1.3)
      activeresource (= 3.1.3)
      activesupport (= 3.1.3)
      bundler (~> 1.0)
      railties (= 3.1.3)
    railties (3.1.3)
      actionpack (= 3.1.3)
      activesupport (= 3.1.3)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.6)
    rake (0.9.2.2)
    rdoc (3.12)
      json (~> 1.4)
    rspec (2.5.0)
      rspec-core (~> 2.5.0)
      rspec-expectations (~> 2.5.0)
      rspec-mocks (~> 2.5.0)
    rspec-core (2.5.2)
    rspec-expectations (2.5.0)
      diff-lcs (~> 1.1.2)
    rspec-mocks (2.5.0)
    rspec-rails (2.5.0)
      actionpack (~> 3.0)
      activesupport (~> 3.0)
      railties (~> 3.0)
      rspec (~> 2.5.0)
    sass (3.1.12)
    sass-rails (3.1.5)
      actionpack (~> 3.1.0)
      railties (~> 3.1.0)
      sass (~> 3.1.10)
      tilt (~> 1.3.2)
    sprockets (2.0.3)
      hike (~> 1.2)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    therubyracer-heroku (0.8.1.pre3)
    thor (0.14.6)
    tilt (1.3.3)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.31)
    uglifier (1.2.0)
      execjs (>= 0.3.0)
      multi_json (>= 1.0.2)
    webrat (0.7.1)
      nokogiri (>= 1.2.0)
      rack (>= 1.0)
      rack-test (>= 0.5.3)
    will_paginate (3.0.2)

PLATFORMS
  x86-mingw32

DEPENDENCIES
  acts-as-taggable-on
  annotate (= 2.4.0)
  coffee-rails (~> 3.1.0)
  factory_girl_rails (= 1.0)
  faker (= 0.3.1)
  gravatar_image_tag (= 1.0.0.pre2)
  jquery-rails
  nested_form
  pg (= 0.11.0)
  rails (= 3.1.3)
  rake
  rspec (= 2.5.0)
  rspec-rails (= 2.5.0)
  sass-rails
  therubyracer-heroku
  uglifier (>= 1.0.3)
  webrat (= 0.7.1)
  will_paginate

application.rb内容:

require File.expand_path('../boot', __FILE__)

require 'rails/all'


if defined?(Bundler)
  Bundler.require(*Rails.groups(:assets => %w(development test)))
end

module AjpApp
  class Application < Rails::Application
    config.encoding = "utf-8"
    config.filter_parameters += [:password]
    config.assets.enabled = true
    config.assets.version = '1.0'
  end
end

config/environments/production.rb 内容:

AjpApp::Application.configure do
  config.cache_classes = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_assets = false
  config.assets.compress = true
  config.assets.compile = true
  config.assets.digest = true
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
end

---已存档---

原帖

我有一个 Rails 3.1 应用程序,它在生产模式下提供 application.css 文件。遇到一些不相关的问题后 https://stackoverflow.com/questions/8554459/more-informative-sass-error-messages我发现关于预编译资产 http://openhood.com/rails/sass/assets/sprockets/2011/05/23/static-assets-on-rails-3.1/ using:

bundle exec rake assets:precompile RAILS_ENV=production

我的 application.css 文件已预编译为生成:“application-79d6fafe46c10758d8f5a921f1e55ecd.css”,但尽管存在于 public/assets 文件夹中,但现在尚未提供服务。 application.js 文件运行良好(如 application-9a36deba94d6308ab9bebe4e30a93959.js)。我还注意到,这个问题在我创建 .css.erb 文件后首先出现,正如文章所建议的预编译 http://openhood.com/rails/sass/assets/sprockets/2011/05/23/static-assets-on-rails-3.1/.

对我尝试做的事情有什么想法吗?我将尝试撤消 .css.erb 文件,再次运行预编译,看看是否可以提供 application.css 文件。

EDIT 1

问题不是来自改变.css文件至.css.erb。而且 erb 工作正常。当asset_path使用函数,例如:

.button_one {
    background-image: url(<%= asset_path "activities/text_editor_toolbar.png" %>);
}

这可以给出正确的字符串,例如:assets/activities/text_editor_toolbar.png",它显示在编译的application-(hash).css文件在开发模式下提供,但不在生产模式下提供。这太奇怪了。 :| :@

Edit 2好吧,这变得更好了,但更奇怪了。似乎如果我在生产模式下运行一次,它就会失败。在开发中再次运行它,然后在生产中再次运行它它将花费很长时间并启动“基于 Microsoft 控制台的脚本主机”,就像预编译资产一样 https://stackoverflow.com/questions/8568786/poor-time-performance-of-rake-assetsprecompile,从输出来看,在最终渲染页面并成功提供 application-(hash).css 之前,它似乎正在执行此操作:

C:\documents\ror\ajp_app>rails s -e production
=> Booting WEBrick
=> Rails 3.1.3 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-12-19 23:59:12] INFO  WEBrick 1.3.1
[2011-12-19 23:59:12] INFO  ruby 1.9.2 (2011-07-09) [i386-mingw32]
[2011-12-19 23:59:12] INFO  WEBrick::HTTPServer#start: pid=4052 port=3000
cache: [GET /] miss


Started GET "/" for 127.0.0.1 at 2011-12-19 23:59:26 +0000
  Processing by PagesController#home as HTML
Rendered pages/home.html.erb within layouts/application (85.0ms)
Rendered layouts/_header.html.erb (2.0ms)
Rendered layouts/_footer.html.erb (1.0ms)
Completed 200 OK in 393ms (Views: 382.0ms | ActiveRecord: 10.0ms)
cache: [GET /assets/application-a05ca896e645eacb50266c7866d18a0f.css] miss


Started GET "/assets/application-a05ca896e645eacb50266c7866d18a0f.css" for 127.0.0.1 at 2011-12-19 23:59:27 +0000
Nonexistent asset application-a05ca896e645eacb50266c7866d18a0f.css @ a05ca896e645eacb50266c7866d18a0f
Served asset /application-a05ca896e645eacb50266c7866d18a0f.css - 404 Not Found (44ms)

ActionController::RoutingError (No route matches [GET] "/assets/application-a05ca896e645eacb50266c7866d18a0f.css"):


Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout
 (1.0ms)
[2011-12-19 23:59:39] INFO  going to shutdown ...
[2011-12-19 23:59:39] INFO  WEBrick::HTTPServer#start done.
Exiting

C:\documents\ajp_app>rails s
=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-12-20 00:00:14] INFO  WEBrick 1.3.1
[2011-12-20 00:00:14] INFO  ruby 1.9.2 (2011-07-09) [i386-mingw32]
[2011-12-20 00:00:14] INFO  WEBrick::HTTPServer#start: pid=2752 port=3000


Started GET "/" for 127.0.0.1 at 2011-12-20 00:00:20 +0000
  Processing by PagesController#home as HTML
  ←[1m←[36m (0.0ms)←[0m  ←[1mSHOW search_path←[0m
  ←[1m←[35mUser Load (1.0ms)←[0m  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Rendered pages/home.html.erb within layouts/application (171.0ms)
Compiled application.css  (4ms)  (pid 2752)
Compiled colours.css  (9ms)  (pid 2752)
Compiled custom.css  (1ms)  (pid 2752)
Compiled activity.css  (26ms)  (pid 2752)
Compiled jquery/jquery-ui-1.8.13.custom.css  (1ms)  (pid 2752)
Compiled ellib/elcommon.css  (30ms)  (pid 2752)
Compiled ellib/eldialogform.css  (0ms)  (pid 2752)
Compiled elrte/elrte.css  (0ms)  (pid 2752)
Compiled activities/text_editor.css  (2ms)  (pid 2752)
Compiled errors.activities.css  (0ms)  (pid 2752)
Compiled errors_and_notices.css  (0ms)  (pid 2752)
Compiled general.css  (0ms)  (pid 2752)
Compiled application.js  (15ms)  (pid 2752)
Compiled jquery.js  (13ms)  (pid 2752)
Compiled jquery_ujs.js  (0ms)  (pid 2752)
Compiled jquery-ui.js  (19ms)  (pid 2752)
Compiled AJP_main.js  (1ms)  (pid 2752)
Compiled ajp.utilities.js  (2ms)  (pid 2752)
Rendered layouts/_header.html.erb (4.0ms)
Rendered layouts/_footer.html.erb (2.0ms)
Completed 200 OK in 1091ms (Views: 1076.0ms | ActiveRecord: 15.0ms)


Started GET "/assets/custom.css?body=1" for 127.0.0.1 at 2011-12-20 00:00:28 +0000
Served asset /custom.css - 304 Not Modified (6ms)


Started GET "/assets/jquery/jquery-ui-1.8.13.custom.css?body=1" for 127.0.0.1 at 2011-12-20 00:00:28 +0000
Served asset /jquery/jquery-ui-1.8.13.custom.css - 304 Not Modified (7ms)


Started GET "/assets/ellib/eldialogform.css?body=1" for 127.0.0.1 at 2011-12-20 00:00:28 +0000
Served asset /ellib/eldialogform.css - 304 Not Modified (5ms)


Started GET "/assets/elrte/elrte.css?body=1" for 127.0.0.1 at 2011-12-20 00:00:28 +0000
Served asset /elrte/elrte.css - 304 Not Modified (5ms)


Started GET "/assets/activities/text_editor.css?body=1" for 127.0.0.1 at 2011-12-20 00:00:28 +0000
Served asset /activities/text_editor.css - 304 Not Modified (9ms)


Started GET "/assets/activity.css?body=1" for 127.0.0.1 at 2011-12-20 00:00:28 +0000
Served asset /activity.css - 200 OK (10ms)


Started GET "/assets/errors.activities.css?body=1" for 127.0.0.1 at 2011-12-20 00:00:28 +0000
Served asset /errors.activities.css - 304 Not Modified (3ms)


Started GET "/assets/errors_and_notices.css?body=1" for 127.0.0.1 at 2011-12-20 00:00:28 +0000
Served asset /errors_and_notices.css - 304 Not Modified (3ms)


Started GET "/assets/general.css?body=1" for 127.0.0.1 at 2011-12-20 00:00:28 +0000
Served asset /general.css - 304 Not Modified (3ms)


Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2011-12-20 00:00:28 +0000
Served asset /jquery.js - 304 Not Modified (12ms)


Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2011-12-20 00:00:28 +0000
Served asset /jquery_ujs.js - 304 Not Modified (8ms)


Started GET "/assets/jquery-ui.js?body=1" for 127.0.0.1 at 2011-12-20 00:00:29 +0000
Served asset /jquery-ui.js - 304 Not Modified (42ms)


Started GET "/assets/AJP_main.js?body=1" for 127.0.0.1 at 2011-12-20 00:00:29 +0000
Served asset /AJP_main.js - 304 Not Modified (3ms)


Started GET "/assets/ajp.utilities.js?body=1" for 127.0.0.1 at 2011-12-20 00:00:29 +0000
Served asset /ajp.utilities.js - 304 Not Modified (10ms)


Started GET "/assets/ellib/elcommon.css?body=1" for 127.0.0.1 at 2011-12-20 00:00:29 +0000
Served asset /ellib/elcommon.css - 304 Not Modified (5ms)


Started GET "/assets/colours.css?body=1" for 127.0.0.1 at 2011-12-20 00:00:29 +0000
Served asset /colours.css - 304 Not Modified (12ms)


Started GET "/assets/activities/hello.png" for 127.0.0.1 at 2011-12-20 00:00:30 +0000
Served asset /activities/hello.png - 404 Not Found (13ms)

ActionController::RoutingError (No route matches [GET] "/assets/activities/hello.png"):


Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout
 (1.0ms)
[2011-12-20 00:00:37] INFO  going to shutdown ...
[2011-12-20 00:00:37] INFO  WEBrick::HTTPServer#start done.
Exiting

C:\documents\ajp_app>rails s -e production
=> Booting WEBrick
=> Rails 3.1.3 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-12-20 00:01:17] INFO  WEBrick 1.3.1
[2011-12-20 00:01:17] INFO  ruby 1.9.2 (2011-07-09) [i386-mingw32]
[2011-12-20 00:01:17] INFO  WEBrick::HTTPServer#start: pid=5912 port=3000
cache: [GET /] miss


Started GET "/" for 127.0.0.1 at 2011-12-20 00:01:20 +0000
  Processing by PagesController#home as HTML
Rendered pages/home.html.erb within layouts/application (91.0ms)
Rendered layouts/_header.html.erb (3.0ms)
Rendered layouts/_footer.html.erb (1.0ms)
Completed 200 OK in 400ms (Views: 387.0ms | ActiveRecord: 12.0ms)
cache: [GET /assets/application-a05ca896e645eacb50266c7866d18a0f.css] miss, store


Started GET "/assets/application-a05ca896e645eacb50266c7866d18a0f.css" for 127.0.0.1 at 2011-12-20 00:01:21 +0000
Compiled application-a05ca896e645eacb50266c7866d18a0f.css  (4ms)  (pid 5912)
Compiled colours.css  (9ms)  (pid 5912)
Compiled custom.css  (0ms)  (pid 5912)
Compiled activity.css  (21ms)  (pid 5912)
Compiled jquery/jquery-ui-1.8.13.custom.css  (1ms)  (pid 5912)
Compiled ellib/elcommon.css  (0ms)  (pid 5912)
Compiled ellib/eldialogform.css  (1ms)  (pid 5912)
Compiled elrte/elrte.css  (1ms)  (pid 5912)
Compiled activities/text_editor.css  (0ms)  (pid 5912)
Compiled errors.activities.css  (1ms)  (pid 5912)
Compiled errors_and_notices.css  (0ms)  (pid 5912)
Compiled general.css  (0ms)  (pid 5912)
Served asset /application-a05ca896e645eacb50266c7866d18a0f.css - 200 OK (871ms)
cache: [GET /assets/application-9a36deba94d6308ab9bebe4e30a93959.js] miss


Started GET "/assets/application-9a36deba94d6308ab9bebe4e30a93959.js" for 127.0.0.1 at 2011-12-20 00:01:22 +0000
Compiled application-9a36deba94d6308ab9bebe4e30a93959.js  (9ms)  (pid 5912)
Compiled jquery.js  (13ms)  (pid 5912)
Compiled jquery_ujs.js  (1ms)  (pid 5912)
Compiled jquery-ui.js  (19ms)  (pid 5912)
Compiled AJP_main.js  (0ms)  (pid 5912)
Compiled ajp.utilities.js  (32ms)  (pid 5912)
Served asset /application-9a36deba94d6308ab9bebe4e30a93959.js - 304 Not Modified (110802ms)
cache: [GET /assets/logo_80px_80px-27d7b084daa398621574b10963529e84.png] miss


Started GET "/assets/logo_80px_80px-27d7b084daa398621574b10963529e84.png" for 127.0.0.1 at 2011-12-20 00:03:13 +0000
Served asset /logo_80px_80px-27d7b084daa398621574b10963529e84.png - 304 Not Modified (3ms)
cache: [GET /assets/hello.png] miss


Started GET "/assets/hello.png" for 127.0.0.1 at 2011-12-20 00:03:13 +0000
Served asset /hello.png - 404 Not Found (3ms)

ActionController::RoutingError (No route matches [GET] "/assets/hello.png"):


Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout
 (1.0ms)

。 。 。 :-D & :-o ?

Edit 3您不需要首先在生产模式下运行它一次(即,它实际上是在开发中运行的行为,它会触发生产模式以(?)重新预编译资产)。使用后rake要预编译资产,只需在开发模式下运行,请求一个页面(其中is必要),然后在生产环境中运行并再次请求主页就足以触发第二次预编译。

现在,我的机器(win 7-64位)完全重新启动后仍然存在。所以我认为这是一个持续存在的错误。

StackOverflow 是继续此讨论的最佳场所还是继续讨论链轮 git-hub 页面 https://github.com/sstephenson/sprockets, 或者其他的东西?


我遇到了完全相同的问题,并通过在 Production.rb 文件中将此选项更改为 true(默认情况下为 false)来解决它。

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = true

据我了解,如果您在 Apache 或 nginx 下运行,则将此选项设置为 false 是有意义的,但我的情况并非如此。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

application.css 未作为资产提供 的相关文章

  • 如何强制折断不可折断的字符串?

    我有一个根据数据库中包含的数据生成的 HTML 页面 数据库有时包含浏览器无法分解的长字符串 因为这些字符串不包含可分解的字符 空格 点 逗号等 有没有办法使用 html css 甚至 javascript 来解决这个问题 看到这个link
  • 如何覆盖 bootstrap 表 td 样式?

    我正在使用 Bootstrap 3 3我有一个 HTML 代码如下 div table class table table striped tr td 03 td td 04 td td 05 td td 06 td td 07 td td
  • 如何准确地衡量加载模型所需的时间?

    我想对加载模块 find by id 234 调用 所需的时间进行基准测试 另外 我如何跟踪加载页面所需的时间 我知道我在运行 Rails 服务器时得到此信息 但这是在调试模式下 我想要生产速度基准 可能吗 为了快速检查 我强烈建议检查基准
  • CSS - div 与父 div 底部对齐(内联块)

    我知道这个 html 很草率 有一些不必要的额外 div 但无论如何 我无法理解为什么 ID 为 info box right 的 div 与父 div 的底部对齐 您可以看到 文本 与下面的 jsfiddle 示例的底部 有什么想法可以让
  • 无法解决 Rails 设置中的错误 - `LoadError: 无法加载此类文件 -- active_storage/engine`

    我正在尝试设置一个新的 Rails 应用程序 但遇到了一个我似乎无法解决的问题 当尝试跑步时rake db drop or rake db create我不断收到错误 LoadError cannot load such file acti
  • rake db 问题:迁移 -

    我无法为 Ruby on Rails 设置 MySQL 数据库 设置数据库并确保 config database yml 文件匹配后 我遇到了以下错误消息 U Rails alpha gt rake db migrate trace in
  • 如何在Rails中使用jquery tokeninput?

    我正在尝试在我的应用程序的表单中添加 tokeninput jquery 字段 该字段允许用户发布状态更新 我希望用户能够将作品 单独的模型 附加到状态更新中 我正在使用 act as taggable on gem 并且我的查询指定标签上
  • 我可以使用同一个 ActionMailer 从不同地址发送电子邮件吗

    我正在为我的 Rails 2 3 9 应用程序使用 ActionMailer 当我使用以下方式发送电子邮件时 deliver user invite config def user invite subject content subjec
  • Ruby on Rails 两个同时创建两个不同控制器的操作

    我有一个线程控制器和消息控制器 线程 has many 消息 用户单击发送后 我将数据发送到线程控制器以创建线程 我想做到这一点 线程控制器 rb def create if thread save send data into messa
  • 动态表单标签宽度的 CSS

    我目前正在重构我们的表单控制器之一 以便我们可以将其用于面向公众的网站 目前它正在为表单生成表格布局 但我正在尝试使用 CSS 表单来完成它 我正在尝试重现看起来像这样的东西http www stylephreak com uploads
  • 如何在不初始化Rails的情况下从schema.rb创建数据库?

    我正在尝试从 schema rb 创建所有表 我使用命令 rake db schema load 但是 这失败了 因为在我的一个初始化程序中 它引用了一个显然不存在的模型 表 因为数据库为空 我可以注释掉这些行 然后再次运行 schema
  • 处理铁路中 STI 子类路线的最佳实践

    我的 Rails 视图和控制器散布着redirect to link to and form for方法调用 有时link to and redirect to它们链接的路径是明确的 例如link to New Person new per
  • div 边框上的内边距

    我想在 css 边框上添加填充 将其拉入 div 内 远离边缘 使用 css 可以吗 css3 很好 webkit 这是设计 我通过将一个 div 放在一个 div 中 然后给内部 div 一个边框来做到这一点 我想让标记尽可能精简 所以如
  • 在 Rails 4 中使用 Strong Params 允许特殊情况下使用额外的参数

    因此 对于一个组织来说 我希望用户能够编辑有关它的一些内容 params require organization permit name location 但在特殊情况下 我希望管理员能够编辑额外的属性 params require or
  • 防止浮动换行,直到元素达到最小宽度

    我有可变宽度的 HTML 布局 内容左侧有一个固定宽度的菜单 div 可变宽度 由 css max width 和 min width 设置 对于非常窄的浏览器窗口 我希望内容包裹在菜单下方 我目前通过设置来实现这一点float left在
  • 更改 en.yml 文件中的属性名称不起作用

    我更改了 ruby on Rails 项目中 en yml 文件中的属性名称 按钮工作正常 但字段属性并没有改变 这是我的模型 class Enr AffordableWarmth lt ActiveRecord Base self tab
  • 如何将此 HTML 表格布局解决方案转换为浮动 div 解决方案?

    我经常需要列出各种尺寸的项目images在左边和text在右边 像这样 替代文本 http www deviantsart com upload 7s01l5 png http www deviantsart com upload 7s01
  • 如何将送货地址复制到帐单地址

    我想知道是否可以将送货地址复制到帐单地址 当用户单击与送货地址相同的复选框时 送货地址值将被复制到账单输入字段 我完成了大部分部分 但我不确定如何将选择菜单 状态 值复制到帐单地址 我真的很感谢任何帮助 My code document r
  • 覆盖并重置 CSS 样式:auto 或 none 不起作用

    我想覆盖为所有表定义的以下 CSS 样式 table font size 12px width 100 min width 400px display inline table 我有一个特定的表 其类名为 other 最后的餐桌装饰应该是这
  • Rails 6:每个用户只能创建一个配置文件

    我目前正在开发 Rails 6 应用程序 我有以下关联 用户有一个配置文件 并且配置文件属于用户 当编辑用户的配置文件时 我最终为该用户提供了两个配置文件 我希望每个用户只有一份个人资料 编辑表单 profile edit html erb

随机推荐

  • 无法将 iTextSharp 与 ASP.NET 5 Core 一起使用

    我正在尝试将 iTextSharp 与 ASP NET 5 Core 一起使用 但是 当我尝试使用 iTextSharp 5 5 5 构建 ASP NET 应用程序时 出现这些错误 Code using Microsoft AspNet M
  • 方法调用 mActionBar=getActionBar() 给出错误[关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 我正在使用支持库android support v7 app actionbar因为我想要操作栏API 级别 8以上 但是下面的句子给了我
  • 频域和空间域的汉明滤波器

    我想通过在 MATLAB 中应用汉明滤波器来消除一维信号中的吉布斯伪影 我所拥有的是k1这是频域中的信号 我可以通过应用 DFT 来获取时域信号k1 s1 ifft ifftshift k1 该信号具有吉布斯伪影 现在 我想通过 A 乘以汉
  • static 和 volatile 关键字的顺序重要吗?

    volatile static int i and static volatile int i 两者有什么区别 编译器如何看待这一点 顺序无关紧要 static是存储时间 6 2 4 对象的存储时长 3 一个标识符为的对象 用外部或内部声明
  • 如何让 mysql 输出 DateTime 到儒略日数?

    基本上我正在使用用于 Ruby 的 MySQL gem http www tmtm org en mysql ruby 并且我对日期比较没有合理的支持 这Mysql Time类只为我提供了访问器方法 如年 月 秒等 如果我可以将其转换为 R
  • 对于“迭代算法”,转换为 RDD 然后再转换回 Dataframe 有什么优势

    我在读高性能火花作者提出以下主张 虽然 Catalyst 优化器非常强大 但它目前遇到挑战的情况之一是非常大的查询计划 这些查询计划往往是迭代算法的结果 例如图算法或机器学习算法 一个简单的解决方法是将数据转换为 RDD 并在每次迭代结束时
  • 回显 HTML 并内置 PHP

    请帮助我使用 echo 与 HTML 和 PHP 使用数组范围将其转换为动态
  • 将 Pi 转换为字母?

    对于 Pi Day 我正在尝试编写一个 Java 程序 尝试在 Pi 中找到给定的单词 或另一个给定的无理数 我几乎已经完成了所有工作 但我对如何将 pi 的每个数字转换为字母感到矛盾 我想说 A 01 B 02 C 03 Y 25 Z 2
  • 在 PHP $_SESSION 中存储数据不安全吗?

    根据我的理解 PHP 进程的行为并不像应用程序服务器进程 因此 执行脚本后 PHP 进程不会保留任何用户特定数据 相反 它将它们存储在用户的 cookie 中 所以无论我们存储在什么地方 SESSSION进入cookie 这是真的 如果是
  • Cordova 插件包括 Android 库 (Gradle)

    我想包括这个 Androidlibrary https github com 50ButtonsEach fliclib android在 Cordova 插件中 该库本身由 Gradle 管理 如 Github 链接所示 图书馆的开发者只
  • DS-5:什么是 FVP、RTSM、基础模型、AEM 模型、快速模型、CADI?

    DS 5 模拟器使用了很多术语 如 FVP RTSM 快速模型 基础模型 AEM 模型 CADI Arm的文档中提供的解释不是很清楚 这些术语的含义是什么 作为 DS 5 的最终用户我应该关心哪些术语 Model 软件模拟的行业术语 就 A
  • 使用 plyr daply 将数据帧转换为矩阵

    我正在尝试使用daply函数在plyr包 但我无法让它正确输出 尽管组成矩阵的变量是数字 但矩阵的元素是列表 而不是变量本身 例如 以下是一小部分数据 Month Vehicle Samples 1 Oct 10 31057 256 2 O
  • 如何将数据插入 Microsoft Access 数据库?

    我正在尝试将数据插入 Microsoft Access 数据库 我将数据插入到 Access 数据库中 但只有第一次和第二次显示我插入的数据 当我重建应用程序时 我插入的数据消失了 我不知道他们去了哪里并且没有出现 我使用 C 和 NET
  • 如何阅读shell命令的源代码?

    我想阅读编写linux命令的实际源代码 我已经获得了一些使用它们的经验 现在我认为是时候与我的机器进行更深层次的交互了 我在这里找到了一些命令http directory fsf org wiki GNU http directory fs
  • 如何在调试模式下更改灯开关应用程序的连接字符串

    请问我如何更改灯开关应用程序的连接字符串以进行调试 我已经关注了这个帖子http dougseven com 2010 08 23 data storage in visual studio lightswitch 2 http dougs
  • 当子可滚动部件到达颤振顶部时,如何自动开始滚动父可滚动部件

    这似乎很自然 甚至可能是预料之中的 但我仍然没有找到任何可能有帮助的东西 我在另一个可滚动小部件 父级 中有一个 ScrollablePositionedList 几乎与 ListView 相同 我尝试过 CustomScrollView
  • 基于不同 ID 的 SSAS 聚合

    我希望将不同 ID 值的默认聚合从 SUM 更改为 SUM 这是当前的行为 ID Amount 1 10 1 10 2 20 3 30 3 30 Sum Total 90 默认情况下 我会收到 90 美元 我希望对不同的 id 进行求和并得
  • 传入字符串作为参数,而不将其视为原始字符串

    我想将一个字符串传递给我的 python 脚本 其中包含转义序列 例如 x00 or t和空格 但是 当我将字符串传递为 some string x00 more tstring python 将我的字符串视为原始字符串 当我从脚本内部打印
  • 使用 CSS 格式化日期/时间或百分比值?

    有没有办法使用 CSS 来使用特定格式格式化日期 例如YYYY MM DD 或 MM DD YYYY 有或没有时间 也可以将数字格式化为保留 2 位小数的百分比值 例如5 4321987 显示为 5 43 我可能可以使用 JavaScrip
  • application.css 未作为资产提供

    编辑4 5和6 8小时后 欢迎任何更多的想法 也许这个错误已经被知道并解决了 但是当你在 app assets stylesheets 的 css erb 文件中有这个时 我得到了我在编辑 2 3 中描述的行为 li background