草庐IT

app-bundle-name

全部标签

ruby-on-rails - Rails 没有在 app/assets/images 文件夹中预编译图像?

我的app/assets/images文件夹中有一些图像(svg)。根据Rails指南,assets文件夹中的所有文件都应该自动预编译。但是,当我使用image_tag('filename')引用图像时,它显示了一个Sprockets::Rails::Helper::AssetNotPrecompiled错误Asset未声明为在生产中预编译。它告诉我手动声明要预编译的文件,但为什么必须这样做?最重要的是,当我在开发中做所有事情时,为什么它会关心生产环境? 最佳答案 如果您在开发中启动服务器后添加了图像,请重新启动服务器。然后Spro

ruby-on-rails - bundle 安装 : ERROR: Failed to build gem native extension. nio4r gem

我目前正在使用以下项目进行项目:rvm1.26.11ruby2.2.1p85我尝试运行bundleinstall但不断收到以下错误:Gem::Ext::BuildError:ERROR:Failedtobuildgemnativeextension.并且,以下:Anerroroccurredwhileinstallingnio4r(1.0.0),andBundlercannotcontinue.Makesurethat`geminstallnio4r-v'1.0.0'`succeedsbeforebundling.当我尝试运行geminstallnio4r-v'1.0.0'时:Buil

ruby - 获取名称错误 : `format' is not allowed as an instance variable name when testing instance variable with rspec

我有以下测试:let(:client){Descat::Client.new}describe'poblacio'doit'shouldsetformatcorrectly'doclient.poblacio('v1','json','dades')expect(client.instance_variable_get(:format)).toeq('json')endend我有以下正在测试的代码:moduleDescatclassClientBASE_URL='http://api.idescat.cat/'definitialize(attributes={})attributes

ruby-on-rails - 如何让 Rails 中的 named_scope 返回一个值而不是数组?

我想写一个namedscope从它的id中获取记录。例如,我有一个名为Event的模型,我想使用named_scope来模拟Event.find(id)future的灵active。我在我的模型中使用了这段代码:named_scope:from_id,lambda{|id|{:conditions=>['id=?',id]}}我从我的Controller调用它,如Event.from_id(id)。但我的问题是它返回一组Event对象而不是一个对象。因此如果我想获取事件名称,我必须写event=Event.from_id(id)event[0].name而我想要的是event=Even

ruby-on-rails - 由于 'eventmachine 1.0.3',无法 bundle 安装

$bundle安装Errno::ENOENT:Nosuchfileordirectory@rb_sysopen-/Users/Sean/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/ext/gem_make.outAnerroroccurredwhileinstallingeventmachine(1.0.3),andBundlercannotcontinue.Makesurethat`geminstalleventmachine-v'1.0.3'`succeedsbeforebundling.$ge

ruby-on-rails - 为什么 "rails s"在 app 目录中不起作用?

我在我的应用程序文件夹中,但命令railss不起作用。我在StackOverflow上阅读了很多帖子,其中大多数似乎来自不在其应用程序目录中的用户。此外,我还构建了一些其他应用程序。我检查了那些,Rails服务器适用于所有这些应用程序。这是唯一一个我无法启动它的地方。whichrails的输出:/Users/jmcrist/.rvm/gems/ruby-2.0.0-p247/bin/railsrailss的输出:MacBook-Pro:first_appjmcrist$railssUsage:railsnewAPP_PATH[options]Options:-r,[--ruby=PAT

ruby-on-rails - rails 4 : how to use named scope with has_many associations

在我的Rails4应用程序项目(模型)has_many视频(模型)中。我在视频模型中有一个命名范围:scope:live,where(is_deleted:0,sent_to_api:1)在我的一个项目View中,我这样做(项目是项目的一个实例):project.videos.live.size我希望得到的是那个特定项目中的项目数量,但我得到的是任何项目中的视频数量。就好像.live不是从.videos返回一个子集而是替换它。我看到它解释了here将命名范围相互链接起来应该与逻辑AND相结合,但是当应用于“关联方法”时[.videos在这种情况下的正确术语]似乎并不即将发生。正确的做法

ruby-on-rails - 当我运行 `bundle exec rake test:prepare` 时它出错了,但是 `bundle exec rake db:test:prepare` 运行正常但有警告。这是怎么回事?

所以根据thislink一个是快捷方式包装器(所以我猜它们是一样的)。当我运行bundleexecrakedb:test:prepare时,我得到了这个错误:Don'tknowhowtobuildtask'test:prepare'/Users/aj/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in`eval'/Users/aj/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/ruby_executable_hoo

ruby - zsh : command not found: bundle (after gem install bundle)

为什么zsh:commandnotfound:bundle在geminstallbundler之后?我尝试设置path=(/usr/local/lib/ruby/gems/2.2/gems/~/bin/bin/sbin/usr/bin/usr/sbin/usr/local/bin/usr/local/sbin)在/etc/zshrc和source/etc/zshrc中无济于事。root@dev:/home/dev#geminstallbundlerSuccessfullyinstalledbundler-1.7.12Parsingdocumentationforbundler-1.7.

ruby-on-rails - 带连接的 Rails named_scopes

我正在尝试创建一个使用连接的named_scope,但尽管生成的SQL看起来正确,但结果却是垃圾。例如:classClip"INNERJOINseriesONseries.id=clips.owner_idINNERJOINshowsonshows.id=series.show_id",:conditions=>"shows.visible=1ANDclips.owner_type='Series'"}(一个剪辑属于一个系列,一个系列属于一个节目,一个节目可以是可见的或不可见的)。Clip.all可以:SELECT*FROM`clips`Clip.visible.all可以:SELEC