草庐IT

asset-module

全部标签

ruby-on-rails - Rails 3.1 引擎的 Assets

应该如何在Rails3.1的引擎中提供Assets?它们应该位于何处,它们可以自动包含在内吗?(originallyaskedbyTomasCelizna) 最佳答案 自动加载所有引擎Assets文件夹的路径。默认情况下不加载Assets本身。这是可以理解的,因为加载是用require_tree.完成的。,它从当前文件夹(即主应用程序Assets文件夹)加载所有css/js,但没有说明引擎Assets。简单的解决方案是要求用户在application.js/css或其他任何需要的地方要求js/css。由于路径加载正确,用户只需指定您

ruby-on-rails - rails Assets 管道 "Cannot allocate memory - nodejs"

我们刚刚从Rails3.0.7升级到Rails3.2.5,并为暂存服务器即时使用Assets管道编译,但有时我们会遇到这个异常!Showing/var/rails/appname/app/views/common/_my_partial.html.hamlwhereline#raised:Cannotallocatememory-nodejs/tmp/execjs20120613-17090-thoc8f.js2>&1Extractedsource(aroundline#):Traceoftemplateinclusion:app/views/layouts/application.h

ruby-on-rails - rake Assets :precompile attempting to connect to database

我正在尝试调试为什么我的应用程序在我运行rakeassets:precompile--trace时尝试连接到我的数据库。我可能在堆栈跟踪中遗漏了一些东西...有人看到相关行吗?DEPRECATIONWARNING:TheInstanceMethodsmoduleinsideActiveSupport::Concernwillbenolongerincludedautomatically.PleasedefineinstancemethodsdirectlyinActionController::Baseinstead.(calledfromat/Users/Kyle/Desktop/s

ruby - "extend self"与 "module_function"相同吗?

extendself和module_function是实现它的两种ruby​​方法,因此您可以在模块上调用方法,如果包含该模块也可以调用它。这些方式的最终结果有什么不同吗? 最佳答案 module_function将给定的实例方法设为私有(private),然后复制并将它们作为公共(public)方法放入模块的元类中。extendself将所有实例方法添加到模块的单例中,保持它们的可见性不变。moduleMextendselfdefa;endprivatedefb;endendmoduleNdefc;endprivatedefd;e

ruby-on-rails - gem 更新后 : test fail with "Asset was not declared to be precompiled in production"

由于我更新了几个gem,所以所有测试都失败并出现错误:ActionView::Template::Error:Assetwasnotdeclaredtobeprecompiledinproduction.AddRails.application.config.assets.precompile+=%w(favicons/manifest.json.erb)toconfig/initializers/assets.rbandrestartyourserverapp/views/layouts/_faviconsheader.html.erb:14:in_app_views_layouts

ruby-on-rails - 反编译开发 Assets 管道

我正在为我的生产环境编译我的Assets管道,它适用于我的所有环境。如何为我的开发环境反编译Assets管道?我检查了我的配置/开发环境,但找不到修复。在此先感谢您的帮助... 最佳答案 要删除预编译Assets,请使用:rakeassets:clean这基本上是删除public/assets目录。如果您需要在特定环境中运行它,您可能需要包含RAILS_ENV变量。 关于ruby-on-rails-反编译开发Assets管道,我们在StackOverflow上找到一个类似的问题:

ruby - class_eval、class_exec、module_eval 和 module_exec 之间有什么区别?

我正在阅读Module文档,但似乎无法理解它们之间的差异以及应该在何处使用。eval与exec有何不同? 最佳答案 我将通过在您的问题中包含instance_{eval|exec}来回答您的问题。{instance|module|class}_{eval|exec}的所有变体都会更改当前上下文,即self的值:classArraypself#prints"Array"43.instance_eval{pself}#prints"43"end现在说说区别。eval版本接受字符串或block,而exec版本只接受block但允许您向其传

ruby-on-rails - rails : I can't call a function in a module in/lib - what am I doing wrong?

我有一个模块保存在/lib中作为test_functions.rb看起来像这样moduleTestFunctionsdefabcputs123endend进入ruby​​脚本/运行程序,我可以看到该模块正在自动加载(良好的配置约定等等......)>>TestFunctions.instance_methods=>["abc"]所以方法是已知的,让我们尝试调用它>>TestFunctions.abcNoMethodError:undefinedmethod`abc'forTestFunctions:Modulefrom(irb):3没有。这个怎么样?>>TestFunctions::a

ruby-on-rails - "rake assets:precompile"给出 punc 错误

我正在尝试为生产预编译我的Assets,但Rails似乎不合作。$bundleexecrakeassets:precompile/home/drderp/.rvm/rubies/ruby-1.9.3-p194/bin/ruby/home/drderp/.rvm/gems/ruby-1.9.3-p194@global/bin/rakeassets:precompile:allRAILS_ENV=productionRAILS_GROUPS=assetsrakeaborted!Unexpectedtokenpunc,expectedpunc(line:213,col:13,pos:5986

ruby module_function 与包含模块

在ruby​​中,我知道可以使用module_function在模块中混合使用模块函数,如此处所示。我知道这是多么有用,因此您可以在不混入模块的情况下使用该函数。moduleMyModuledefdo_somethingputs"helloworld"endmodule_function:do_somethingend我的问题是为什么您可能希望以这两种方式定义函数。为什么不拥有defMyModule.do_something或defdo_something在什么样的情况下,将函数混入或用作静态方法会有用? 最佳答案 想到Enumer