ruby

require jruby seems to work and fail simultaneously

John-Breedloves-Mac-mini:~ john_breedlove$ irb >> require 'jruby' => true >> require 'zxing' RuntimeError: ZXing requires JRuby from /Library/Ruby/Gems/1.8/gems/zxing-0.1.1/lib/zxing.rb:1 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require' from /System/Li...

Get HTTP response Using Shoulda Ruby on Rails

I'm migrating over to shoulda from rspec and I can't seem to get access to the http response. Can someone point out what I may be doing wrong? context "doing somethin" do setup do get :index end @response.body should respond_with :success end When i run this i get an error saying that @response is a...

Deploying rake task to server

I have a couple simple rake tasks hosted at github that I would like to push to a remote server. It's essentially just a directory with a few classes and a Rakefile. What would be the best and/or simplest approach for deployment? I'm thinking the simplest might be just to clone the repo on my server and do a git pull whenever there's an...

Issues with Relationships

You can take a look at the app I'm referring to at: http://github.com/585connor/QA So, I've built this question & answer app... kind of. I can get the answers to be listed on their respective questions but I cannot figure out how to get the user info to be displayed on those questions/answers. For example I'd like to put the username ne...

Sinatra message Queue

Starling is a great (at least for small projects) and simple message queue, however, it doesn't actually manage or start workers that consume the queues. Workling does this for Rails projects, but doesn't work for pure ruby applications, neither for Sinatra. Before I fork workling, or create my own custom one with threads/fork, is there...

unable to install gems using `sudo`

I have just setup a new Ubuntu 10.04 PC and am trying to install some gems. gerhard@superserver:~$ sudo gem install rake ERROR: http://gems.rubyforge.org/ does not appear to be a repository ERROR: could not find gem rake locally or in a repository gerhard@superserver:~$ I thought it was because my HTTP_PROXY was set incorrectly (I a...

Routing Error: Uninitialized constant in Rails 3

I have a file containing a helper class something like this: app/classes/myfile.rb Module mymodule class myclass # blah blah end end I want to use this class in a controller, so I wrote something like this: require 'myfile' class MyController < ApplicationController include mymodule def index mymodule::myclass.n...

How do I check whether a value in a string is an IP address

when I do this ip = request.env['REMOTE_ADDR'] I get the client's IP address it it. But what if I want to validate whether the value in the variable is really an IP? How do I do that? Please help. Thanks in advance. And sorry if this question is repeated, I didn't take the effort of finding it... ...

What are the differences between a proc and lambda?

Key differences between proc and lambda? What is a lambda and what is a proc? And how are they each used? ...

Is there a full implementation for ISO-8601 date parsing for Ruby

The Time.iso8601 method is a restricted subset of ISO-8601. Does anyone know what the limitations are? Does anyone know of a full implementation for Ruby? I'm using MRI 1.8.7 Thanks Update It looks like there isn't a single class that handles all of the various 8601 date and date/time combinations. However I have managed to wo...

Getting undefined method content_for()

Hi, my mac just broke and I had to migrate to an Ubuntu machine. I am working on an app that is already on production on an Ubuntu machine as well. I cloned this app into my new machine and all the view helpers seems to go missing, btw I am ussing HAML. I ran my specs and I am getting tons of : undefined method url_for for # und...

Ruby plugin for web browser?

Am I correct that if someone wrote a Ruby plugin for a web browser and a user installed that plugin then it would be possible to replace javascript with ruby on the frontend? Aren't there any plugins for this? Or even for using other languages than javascript on the browser side? ...

Rake task rails:upgrade:check is not working on windows. Rails 3 Upgrade problem.

Is there any solution to solve the problem of rake task rails:upgrade:check on windows ? ...

How to determine which view to render in a controller action

Okay, I have a few different of ideas of how I would achieve this, but thought I would ask here in case someone has a better solution. I have a SessionsController that has a login view and a widget_login view. I was wondering how to go about determining which view to render in the new action of SessionsController. Right now, everythin...

Memcached always miss (rails)

Hi Stackoverflowers, I have spent way too much time on this issue to keep my sanity so it is time to ask for help... I have a class with this method: def telecom_info Rails.cache.fetch("telecom_info_for_#{ref_num}", :expires_in=> 3.hours) do info = Hash.new(0) Telecom::SERVICES.each do |source| results = Tele...

How can I get a key => value out of this foursquare hash?

Here is what it looks like: { "groups" => [ { "venues" => [ { "city" => "Madrid", "address" => "Camino de Perales, s/n", "name" => "Caja Mágica", "stats" => {"herenow"=>"0"}, "geolong" => -3.6894333, "primarycategory" => { "iconurl" => "http://foursquare.com...

Changing the timestamp of magic columns (Rails)

I want to change the default timestamp of the magic columns of rails (created_at, modified_at) instead of 2010-09-03 14:52:46 UTC I'd like to change it to September 10, 2010 at 02:52 PM. or at least parse that way. Now, i know that i can do this right in the view, by manipulating the variable, but isnt there a more "railish way" where ...

What is the best way of running shell commands from a web based interface?

Imagine a web application that allows a logged in user to run a shell command on the web server at the press of a button. This is relatively simple in most languages via some standard library os tools. But if that command is long running you don't want your UI to hang. Again this is relatively easy to deal with using some sort of backgr...

Why are scripting languages (e.g. Perl, Python, Ruby) not suitable as shell languages?

What are the differences between shell languages like bash, zsh, fish and the scripting languages above that makes them more suitable for the shell? When using the command line the shell languages seem to be much easier. It feels for me much smoother to use bash for example than to use the shell profile in ipython, despite reports to th...

Rails 3 - Testing if View calls a method

Hi, I'm starting to learn Rails. I'm using Rails 3. In my simple App, I have the following code: <% @tasks.each do |task| %> ... <td><%= friendly_estimate task.estimate, { :compact => true } %></td> ... <% end %> The mission for me is that I would like to test if the view really sends the :compact option to my method to ensu...