タグ付けされた質問 「ruby」

Rubyは、マルチプラットフォームのオープンソースの動的オブジェクト指向インタープリタ言語であり、1995年に松本幸宏(Matz)によって作成されました。[ruby]タグは、Ruby言語に関連する質問(構文やライブラリなど)を対象としています。Ruby on Railsの質問は[ruby-on-rails]でタグ付けする必要があります。



18
指定した認証メカニズムはサポートされていません。AWS4-HMAC-SHA256を使用してください
AWS::S3::Errors::InvalidRequest The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.新しいフランクフルト地域のS3バケットにファイルをアップロードしようとすると、エラーが発生します。すべてはUS Standardリージョンで正しく動作します。 脚本: backup_file = '/media/db-backup_for_dev/2014-10-23_02-00-07/slave_dump.sql.gz' s3 = AWS::S3.new( access_key_id: AMAZONS3['access_key_id'], secret_access_key: AMAZONS3['secret_access_key'] ) s3_bucket = s3.buckets['test-frankfurt'] # Folder and file name s3_name = "database-backups-last20days/#{File.basename(File.dirname(backup_file))}_#{File.basename(backup_file)}" file_obj = s3_bucket.objects[s3_name] file_obj.write(file: backup_file) aws-sdk(1.56.0) それを修正するには? ありがとうございました。


1
sumがinject(:+)よりもはるかに速いのはなぜですか?
Ruby 2.4.0でいくつかのベンチマークを実行していて、 (1...1000000000000000000000000000000).sum すぐに計算しますが (1...1000000000000000000000000000000).inject(:+) 時間がかかるので、操作を中止しました。Range#sumエイリアスという印象を受けましたRange#inject(:+)が、そうではないようです。では、どのように機能するのでしょうか。sumなぜそれがこれよりもはるかに高速なのinject(:+)でしょうか。 注意Enumerable#sum(によって実装されているRange)のドキュメントは、遅延評価について、またはそれらの線に沿って何も述べていません。
129 ruby 

2
複数のパラメーターを渡すruby sendメソッド
オブジェクトを作成してメソッドを動的に呼び出そうとする Object.const_get(class_name).new.send(method_name,parameters_array) うまくいっているとき Object.const_get(RandomClass).new.send(i_take_arguments,[10.0]) 間違った数の引数をスローする Object.const_get(RandomClass).new.send(i_take_multiple_arguments,[25.0,26.0]) 定義されているランダムクラスは class RandomClass def i_am_method_one puts "I am method 1" end def i_take_arguments(a) puts "the argument passed is #{a}" end def i_take_multiple_arguments(b,c) puts "the arguments passed are #{b} and #{c}" end end 誰かが動的にルビメソッドに複数のパラメータを送信する方法を手伝ってくれる?
129 ruby 

8
コマンドrbenv installがありません
でUbuntu 10.04インストールしましたrbenv。installコマンドがありません。 rbenv 0.4.0-49-g8b04303 Usage: rbenv <command> [<args>] Some useful rbenv commands are: commands List all available rbenv commands local Set or show the local application-specific Ruby version global Set or show the global Ruby version shell Set or show the shell-specific Ruby version rehash Rehash rbenv shims (run this …

6
xxxのコピーがモジュールツリーから削除されましたが、まだアクティブです
エラーはTenantIdLoaderモジュールの実際のコンテンツとは何の関係もないと確信しています。代わりに、ActiveSupport依存関係と関係があります。 このエラーを乗り越えられないようです。私が読んだことから、それActiveRecord::BaseはリロードされているかリロードされているためCompany::TenantIdLoaderであり、どういうわけかそれを伝えていません。助けてください!Rails 4.2にアップグレードできるようになりたいです。 編集 Tenantこれは、自動的に再読み込みされるリファレンスを参照しているためです。しかし、実際にクラスを参照できるようにする必要があるので、これを回避する方法を誰かが知っていますか? config / application.rb config.autoload_paths += %W( #{config.root}/lib/company ) config / initializers / company.rb ActionMailer::Base.send(:include, Company::TenantIdLoader) lib / company / tenant_id_loader.rb module Company module TenantIdLoader extend ActiveSupport::Concern included do cattr_accessor :tenant_dependency self.tenant_dependency = {} after_initialize do self.tenant_id = Tenant.active.id if self.class.tenant_dependent? and self.new_record? and Tenant.active.present? and …


13
Ubuntuレールのインストールがzlibで失敗する
開発ボックスとしてUbuntu 8.10に移動しました。これは、日常的に使用するOSとしてのLinuxへの私の最初の真剣な進出であり、Railsを実行するのに苦労しています。私はすべてがうまくいくように見えるいくつかのチュートリアルに従ってきましたが、何かにgem installまたはgem updateを使用しようとすると、次のようなエラーが発生します。 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- zlib (LoadError) from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:1 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/commands/update_command.rb:5 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:167:in `load_and_instantiate' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:88:in `[]' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:144:in `find_command' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:131:in `process_args' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:102:in `run' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:58:in …


7
Xは既に有効になっていますが、GemfileにはYが必要です
実行するrakeと、次のエラーが発生します。 rake 0.9.2はすでに有効化されていますが、Gemfileにはrake 0.8.7が必要です。bundle execの使用を検討してください。 のbundle exec rake代わりにを使用するとrakeうまくいくようですが、これを修正するための最良の方法ですか?
128 ruby  rubygems  bundler 


6
JavaScriptでのRubyの|| =(または同等)?
Rubyの||=メカニズムが大好きです。変数が存在しないかである場合は、変数nilを作成し、それを何かに等しく設定します。 amount # is nil amount ||= 0 # is 0 amount ||= 5 # is 0 私は今、JavaScriptで同様のことをする必要があります。これを行うための慣習または適切な方法は何ですか?||=構文が無効であることはわかっています。それを処理する2つの明白な方法は次のとおりです。 window.myLib = window.myLib || {}; // or if (!window.myLib) window.myLib = {};
128 javascript  ruby  syntax 


弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.