Why Do Heroku Stack Traces indicate Ruby 1.9.1 is in use?

Recently saw this stack trace on our Heroku app on cedar /usr/local/lib/ruby/1.9.1/uri/common.rb:156:in `split’ /usr/local/lib/ruby/1.9.1/uri/common.rb:174:in `parse’ /usr/local/lib/ruby/1.9.1/uri/common.rb:628:in `parse’ Why is it using Ruby 1.9.1? My Gemfile is not specifying a Ruby version. Heroku’s docs suggest that we should be getting the Cedar default of 1.9.2 https://devcenter.heroku.com/articles/ruby-versions EDIT: ruby -v appears to report the correct version $ […]

delete from array returning self

If I want to delete some elements from an Array and return itself, are foo1 and foo2 below (foo2 when there is only one element to delete) the right way to do it? class Array def foo1 *args; delete_if{|x| args.include?(x)} end def foo2 arg; delete(arg); self end end

How to compare two instance variables from the same class in Ruby?

There is a class called DNA. a variable called nucleotide gets initialized. In the class the length of the nucleotide is found, two different nucleotides are checked to see if they are equal, and the hamming distance is displayed. ‘ My problem is Ruby only interprets one instance of nucleotide. How do I compare nucleotide […]

Rails 4 / postgresql 9.4 – Query and update a ruby object inside an array

I have a method (find_by_sql) that outputs a ruby object inside an array like this: [#<deal id: 66480, opportunity_id: 4, admin_user_id: 1, created_at: “2015-09-20 18:37:29”, updated_at: “2015-09-20 18:37:29”, deal_available: true>] How can I update the object’s ‘deal_available’ attribute inside my database in raw postgresql ? I tried different ways to write it but I stumble […]

How to add .erb file in existing model in rhoMobile

I have created a simple application and edited the index.erb file so that I have a simple view with a text box and a button. Now when i click on that button i want it to navigate to a new view. I know that we can add models and in that models we have different […]

Mavericks system Ruby and gem broken

When I tried to run ruby -v or gem -v (or any other command), I get: dyld: lazy symbol binding failed: Symbol not found: _ruby_run Referenced from: /usr/local/bin/ruby Expected in: /usr/lib/libruby.dylib dyld: Symbol not found: _ruby_run Referenced from: /usr/local/bin/ruby Expected in: /usr/lib/libruby.dylib This is after I ran rvm system to temporally switch to the system […]

Convert string to symbol/keyword

We can convert strings to symbols in the following way: “string_to_symbol”.to_sym # => :string_to_symbol How do I convert strings in the new way of defining keywords? Expected outcome: # => string_to_symbol: I call keywords dynamically, and I end up using => to assign a value to it. I prefer not to do it that way […]

What is wrong in this if structures?

I have the method, which shows me the error : “syntax error, unexpected end-of-input, expecting keyword_end”. Where i made a mistake ? def clicked(p,u) if (Like.where(post_id: p.id).empty?) return false else posts=Like.where(post_id: p.id) if ((posts.length<1) && (posts[0].user_id==u.id) && (posts[0].action!=nil))==true then return true else if ((posts.length<1) && (posts[0].user_id!=u.id)) then return false else posts.each do |i| if (i.user_id==u.id) […]

Thin + EventMachine fails to start

While loading a Thin webserver for a sinatra app I keep getting Unable to load the EventMachine C extension; To use the pure-ruby reactor, require em/pure_ruby'<path>/vendor/bundle/ruby/1.9.1/gems/eventmachine-1.0.0.rc.4/lib/eventmachine.rb:8:in `require’: cannot load such file — rubyeventmachine (LoadError) from <path>/vendor/bundle/ruby/1.9.1/gems/eventmachine-1.0.0.rc.4/lib/eventmachine.rb:8:in `<top (required)>’ from <path>/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin.rb:7:in `require’ from <path>/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin.rb:7:in `<top (required)>’ from <path>/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/bin/thin:5:in `require’ from <path>/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/bin/thin:5:in `<top (required)>’ from <path>/vendor/bundle/ruby/1.9.1/bin/thin:19:in `load’ […]

Using a variable in a heredoc

How can I use a Ruby variable in a heredoc? For instance: <<XML <?xml version=”1.0″ encoding=”ISO-8859-1″ standalone=”no”?><data password=”topsecret”></data> XML How can I set the password with a Ruby variable?

Ruby is the best programming language in the world - Ruby on Rails.