Tag: rubygems

无法安装gitlab-5.0。 我无法完成安装

我在Ubuntu 10上安装gitlab-5.0,当我在gitlab安装指南的Ruby部分执行’sudo gem install bundler’命令时,它向我展示了下一个冲突: root@ubuntu:/home/gitlab/gitlab# sudo gem install bundler Successfully installed bundler-1.3.4 Installing ri documentation for bundler-1.3.4 /usr/lib/ruby/1.8/rdoc/rdoc.rb:280: warning: conflicting chdir during another chdir block /usr/lib/ruby/1.8/rdoc/rdoc.rb:287: warning: conflicting chdir during another chdir block Done installing documentation for bundler after 8 seconds 1 gem installed root@ubuntu:/home/gitlab/gitlab# 然后,在Gems部分 …… root@ubuntu:/home/gitlab/gitlab# sudo gem install charlock_holmes –version ‘0.6.9’ […]

问题在ruby中支持双向语法

我有一种情况需要调用这样的东西: class Office attr_accessor :workers, :id def initialize @workers = [] end def workers worker type = worker.type resp = Worker.post(“/office/#{@id}/workers.json”, :worker => {:type => type}) worker = Worker.new() resp.to_hash.each_pair do |k,v| worker.send(“#{k}=”,v) if worker.respond_to?(k) end self.workers << worker end end 工人阶级 class Worker attr_accessor :office_id, :type, :id def initialize(options={}) @office_id = options[:office].nil? ? nil […]

无法使用ruby脚本从amazon s3删除文件

我正在使用aws-sdk-ruby来删除我的amazon s3帐户中保存在存储桶中的文件,但我无法弄清楚为什么我能够使用以下代码从S3存储桶中删除所需的文件。 这是我的代码 require ‘aws-sdk-v1’ require ‘aws-sdk’ ENV[‘AWS_ACCESS_KEY_ID’] = “XXXXXXX” ENV[“AWS_SECRET_ACCESS_KEY”] = ‘/ZZZZZZZZ’ ENV[‘AWS_REGION’] = ‘us-east-1’ s3 = Aws::S3::Resource.new bucket = s3.bucket(‘some-bucket’) obj = bucket.object(‘https://s3.amazonaws.com/some-bucket/38ac8226-fa72-4aee-8c3d-a34a1db77b91/some_image.jpg’) obj.delete

如何在1.9.2上安装SystemTimer?

我刚刚使用RVM将我的应用程序从1.8.7升级到1.9.2,并且不得不添加RubyGems和Bundler,运行bundle install并使一切工作除了SystemTimer。 Google-fu没有任何回报,我看到其他人在1.9中遇到了问题,但有些人已经开始工作了。 有任何想法吗? pawel:bodb pawel$ sudo gem install SystemTimer Building native extensions. This could take a while… /Users/pawel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/ext/builder.rb:48: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777 ERROR: Error installing SystemTimer: ERROR: Failed to build gem native extension. /Users/pawel/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb creating Makefile make /usr/bin/gcc-4.2 -I. -I/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-darwin10.3.0 -I/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/Users/pawel/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -O3 […]

安装CocoaPods的问题

我想在OSX中设置CocoaPods(我正在运行10.8.2) – 所以我跑了 sudo gem install cocoapods 它成功了,我得到了 – ‘成功安装cocoapods-0.17.2 1 gem安装’ 然后……我尝试pod setup ‘-bash:pod:command not found’ 如何让命令行识别此命令?

如何重定向回我目前所在的页面?

在我的用户相册页面中,他们会看到他们上传的照片,每张照片上都有一个“默认设置”链接。 当用户点击make default ,照片的ID将存储在我的个人资料表的photo_id列中。 问题是将它们重定向回: localhost:3000/settings/photo_gallery/:id 有没有办法可以使用刚刚设置为默认照片的ID重定向回相册? Rails可以通过查看照片的ID来查找我想要重定向的相册,因为照片属于相册,相册中有很多照片吗? 我的数据库中有以下表格: 用户:有一个个人资料,有很多PhotoAlbums 个人资料:属于用户 PhotoAlbum(s):属于用户,有很多照片 图片:属于PhotoAlbum 控制器动作: def set_default_profile_photo photo = Profile.find_by_user_id(current_user.id) photo.photo_id = params[:photo_id] photo.save redirect_to “**HERE IS WHERE I’D LIKE TO REDIRECT TO THE PHOTOALBUM THE PHOTO IS IN**” flash[:success] = “Default photo set!” end 我的路线: users GET /users(.:format) {:action=>”index”, :controller=>”users”} POST /users(.:format) {:action=>”create”, :controller=>”users”} new_user […]

无法在Windows上为rails 3安装mysql2

没有错误消息无法安装mysql2。 我已经尝试过各种我能想到的方法,包括使用devkit。 gem install mysql2 — –with-mysql-include=c:/xampp/mysql/inclu de –with-mysql-lib=c:/xampp/mysql/lib –with-mysql-config=c:/xampp/mysql/bin/my sql_config Temporarily enhancing PATH to include DevKit… Building native extensions. This could take a while… ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. C:/RailsInstaller/Ruby192/bin/ruby.exe extconf.rb –with-mysql-include=c:/xampp/ mysql/include –with-mysql-lib=c:/xampp/mysql/lib –with-mysql-config=c:/xampp/m ysql/bin/mysql_config checking for rb_thread_blocking_region()… yes checking for main() in -llibmysql… no *** extconf.rb […]

gem install mysql失败

我按照http://geryit.com/blog/2011/01/installing-mysql-with-rails-on-mac-os-x-snow-leopard/上的说明进行操作,包括通过macport安装ruby。 每当我执行gem install mysql时 ,我都会收到以下错误 bash-3.2# gem install mysql Building native extensions. This could take a while… ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /opt/local/bin/ruby extconf.rb checking for mysql_ssl_set()… no checking for rb_str_set_len()… no checking for rb_thread_start_timer()… no checking for mysql.h… no checking for mysql/mysql.h… no *** extconf.rb failed *** Could […]

获取资产管道路径中的Gem供应商文件

我创建了一个gem,其中包含来自bootstrap-sass和bootstrap本身的样式表和javascripts的供应商目录。 目录结构是bootstrap-sass-gem / vendor / assets / javascripts 和 引导 – 萨斯 – gem/供应商/资产/样式表 我在测试项目中需要gem,但每当我尝试从gem中获取某些内容时,我都会收到Sprockets::FileNotFound错误。 例如,在application.css中我添加了*= require bootstrap 。 bootstrap位于bootstrap-sass-gem/vendor/assets/stylesheets/bootstrap.scss ,因此我的计算应该包含在资产管道中。 我正在运行RVM Ruby 1.9.2和Rails 3.1。 这是我的配置文件: $:.push File.expand_path(“../lib”, __FILE__) # Maintain your gem’s version: require “bootstrap-sass-gem/version” # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = “bootstrap-sass-gem” s.version = BootstrapSassGem::VERSION s.authors = […]

是否有像Perl的LWP for Ruby这样的模块?

在Perl中有一个LWP模块 : libwww-perl集合是一组Perl模块,它为万维网提供简单而一致的应用程序编程接口(API)。 该库的主要重点是提供允许您编写WWW客户端的类和函数。 该库还包含更常用的模块,甚至包含可帮助您实现简单HTTP服务器的类。 Ruby有类似的模块(gem)吗? 更新 以下是我从特定网站中提取URL的function示例。 use LWP::UserAgent; use HTML::TreeBuilder 3; use HTML::TokeParser; sub get_gallery_urls { my $url = shift; my $ua = LWP::UserAgent->new; $ua->agent(“$0/0.1 ” . $ua->agent); $ua->agent(“Mozilla/8.0”); my $req = new HTTP::Request ‘GET’ => “$url”; $req->header(‘Accept’ => ‘text/html’); # send request $response_u = $ua->request($req); die “Error: “, $response_u->status_line unless $response_u->is_success; my […]