Tag: gem

to_json在Rails中返回字符串而不是json

下面的代码应该返回一个json: @series = @series.map do |serie| { :name => serie.name, :id => serie.id } @series.to_json 它的回报如下: “[{\”name\”:\”Barra\”,\”id\”:3},{\”name\”:\”Botafogo 1\”,\”id\”:1},{\”name\”:\”Botafogo 2\”,\”id\”:2},{\”name\”:\”Tijuca\”,\”id\”:4}]” 为什么它返回一个字符串而不是一个json? ‘json’gem在我的.rb文件的顶部都安装并需要

Ruby on Rails – Carrierwave获取图像尺寸宽度和高度

我需要知道当前载波实例的宽度和高度 例如: image_tag image.photo_url,:width => image.photo.width, :height => image.photo.height 但问题是image.photo.width和image.photo.height不起作用。 有任何想法吗 ?

捆绑安装我的Rails应用程序冻结

有时在使用Rails应用程序时,运行bundle install命令会在处理Rails Gemfile时冻结。 我已经尝试清除缓存,没有任何改进。

使用javascript_include_tag的Ruby On Rails错误

所以我的问题,从我所知,似乎是ruby没有加载它的所有javascript文件,因为我没有得到确认消息和link_to方法:: delete对我没有任何作用。 随着默认设置提供给我rails新 views / layouts / application.html.erb head section如下。 Myrubyblog true %> true%> 这给了我错误 Started GET “/posts” for 127.0.0.1 at 2015-02-27 02:14:57 -0600 ActiveRecord::SchemaMigration Load (0.0ms) SELECT “schema_migrations”.* FROM “schema_migrations” Processing by PostsController#index as HTML Post Load (1.0ms) SELECT “posts”.* FROM “posts” Rendered posts/index.html.erb within layouts/application (11.0ms) Completed 200 OK in 76ms (Views: 54.0ms […]

在ubuntu上运行mysql gem问题

Ruby on Rails:我想在localhost上调用一个控制器,但服务器说!!! 缺少mysql gem。 将它添加到您的Gemfile:gem’mysql’,’2.8.1′ 问题 ? 当我点击’gem list’命令然后我得到一个列表女巫包含mysql 2.8.1。 所以gem是安装的! 为什么不能通过webrick看到它? 谢谢。

没有这样的文件加载 – 机架

有时,即使安装了机架,我的rails应用程序也会出错(没有这样的文件可以加载 – 机架)。 [Gemfile] gem’ rack’,’1.2.1′ 如果我刷新页面,它加载正常。 所以这不是gem问题。 什么可能导致错误? 谢谢。 山姆

rails 4:在第2行第11列(Psych :: SyntaxError)的上下文中不允许映射值?

我已经成功安装了rails 4并使用rails 4.0.0创建了项目 rails s 这是第一次工作正常。 但在gemfile中添加’devise’gem后 gem ‘devise’, ‘~> 3.0.0.rc’ 并运行bundle install,我收到以下错误。 这个错误的原因是什么,它的解决方案是什么? 我也试过评论gem’devise’部分,但现在我得到的每个rails命令都有相同的错误。 /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse’: (): mapping values are not allowed in this context at line 2 column 11 (Psych::SyntaxError) from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse_stream’ from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:153:in `parse’ from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:129:in `load’ from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/config_file.rb:318:in `load_file’ from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/config_file.rb:191:in `initialize’ from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/gem_runner.rb:66:in `new’ from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/gem_runner.rb:66:in `do_configuration’ from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/gem_runner.rb:46:in […]

在rails中的gem中设置tesseract OCR时出错

我正在尝试在我的rails环境中设置tesseract-ocr gem。 我已经运行了brew install tesseract ,然后在应用程序上运行了一个bundle install,并且所有运行都没有错误,但是当启动应用程序( rails s )时,抛出以下错误: /Users/xxxx/.rvm/gems/ruby-1.9.2-p290@xxxx/gems/ffi-inline-0.0.4.3/lib/ffi/inline/compilers/gcc.rb:35:in `compile’: compile error: see logs at /var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.log (CompilationError) 它引用了以下日志文​​件: g++ -dynamic -bundle -fPIC -L/usr/local/Cellar/tesseract/3.02.02/lib -I/usr/local/Cellar/tesseract/3.02.02/include -o /var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.dylib /var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.cpp -llept 2>>/var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.log /var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.cpp:1:10: fatal error: ‘leptonica/allheaders.h’ file not found #include 我遵循了以下两个问题: https : //github.com/meh/ruby-tesseract-ocr/issues/3和https://github.com/meh/ruby-tesseract-ocr/issues/21 它谈到了我已经完成的设置ENV变量。 我在initalizers文件夹中创建了一个test.rb文件,其中包含以下变量: ENV[‘CFLAGS’] = ‘-I/usr/local/Cellar/tesseract/3.02.02/include’ ENV[‘LDFLAGS’] = ‘-L/usr/local/Cellar/tesseract/3.02.02/lib’ 但是,这对启动应用程序时的错误没有任何影响。 当它说更新标题时我不明白它意味着什么。 我想知道是否有人能告诉我到底要做些什么才能让这个工作。 谢谢。

Ruby on Rails推送通知

是否有任何gem,我可以使用任何东西在Rails应用程序中将通知从服务器推送到Web应用程序? 这意味着不必不时调用ajax请求。 ::更新::忘了提到一个重要的要求,即我正在使用Rails 3.2

使用MAMP 2.2在Mac上“gem install mysql2”

当我尝试在我当前的目录(这是一个新的rails项目)中运行rails server时,它说我需要安装mysql2 gem。 起初,我不知道这意味着什么……然后,我做了一些戳,最后决定安装gem。 但是,我得到了这个超级麻烦的错误(因为我只花了2个小时试图调查,并解决了另一个错误)。 我正处于放弃的边缘,但我真的想试试铁轨。 请帮忙! 目前,如果我运行sudo gem install mysql2 ,或者甚至有些人告诉我在线做, gem install mysql — \ –with-mysql-config=/Applications/MAMP/Library/bin/mysql_config (我有MAMP) ,它给我以下错误: Building native extensions. This could take a while… ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /Users/vicky/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb checking for ruby/thread.h… yes checking for rb_thread_call_without_gvl() in ruby/thread.h… yes checking for rb_thread_blocking_region()… yes […]