ruby

Current version of the rmagick gem (2.13.1) doesn't work with current version of ImageMagick (6.6.4)

I'm on OSX Snow Leopard though I think this may not be a platform-specific issue. The problem is I've wasted hours of my life trying to get gem install rmagick to work and I'm hoping to save the next person that grief. I believe the core problem is summed up in the title. Questions: Can anyone confirm that Rmagick 2.13.1 doesn't work ...

Ruby: Array contained in Array, any order

Suppose I have the following Ruby code: array_1 = ['a', 'b'] array_2 = ['a', 'b', 'c'] some_function(array_1, array_2) # => True some_function(array_2, array_1) # => False some_function(['a', 'b'], ['a', 'd']) # => False some_function(['x', 'y'], array_2) # => False I am pretty much looking for some_function to return True when Param...

Keep getting nil error everywhere. ruby/rails 3

I get a NoMethodError: undefined method `get_best_compatible' for nil:NilClass in mail `from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/whiny_nil.rb:48:in 'method_missing'from /usr/lib/ruby/gems/1.8/gems/mail-2.2.7/lib/mail/body.rb:143:in 'get_best_encoding' from /usr/lib/ruby/gems/1.8/gems/mail2.2.7/lib/mail/mes...

What's the javascript equivalent of ruby's "inspect"?

In ruby, you can do foo.inspect() and it outputs something sane for any object pretty much regardless of type. How do I achieve the same thing in Javascript? ...

Before save action... split input field

Hi there, I have two models and controllers: Snippets, and Tags. There is a belongs_to relationship, with tags belonging to snippets. This works well, I have a text field which creates a new tag associated with the snippet when the user submits a snippet. I want to be able to have a text field which, when submitted to a function (in t...

deriving functions in ruby

HI everyone, I need to take the derivative of the following function in ruby: 1/(1-exp(-x)) I would like to do this symbolically equivalent to -- Analytically Is there a ruby command to do this, or gem? Ted. ...

Neither ruby and nor irb can load .rb file in current directory

I'm having a really noob problem with importing files in Ruby. I'm making a Ruby app in Windows XP. All the class files for the app are in "C:/Documents/Prgm/Surveyor_Ruby/lib". But when I require a file in another file, neither ruby nor irb can find the required file. The current directory's contents: C:\Documents\Prgm\Surveyor_Ruby\l...

Does any one have a complete sample ruby program (with sources) using sqlite3 + datamapper

I've been trying to figure out how to use the datamappings in a real ruby program. After I code all of my mappings, then what? How do I use it in a real program? If any one has a sample program that I can look through the codes, it would help me out tremendously. Thank you. ...

Rails 3 Authlogic - 'acts_as_authentic' undefined

I'm getting the following error: NameError (undefined local variable or method `acts_as_authentic' for #<Class:0x1037e6310>): app/models/user.rb:2 app/controllers/user_controller.rb:3:in `new' I'm using Rails 3.0.0, with Ruby 1.8.7. Authlogic is in my Gemfile as follows: gem 'authlogic', :git => "git://github.com/binarylogic/auth...

Using Rails to build a GUI for an existing CLI Ruby script?

G'day guys, Currently having a bit of a philsophical conundrum. Myself and a few mates have built a quite awesome ruby CLI script for parsing and managing data. It uses gems, responds to requests and is fully functional and great. I was wondering if there was any way I could hold a singleton instance of this class and interact with it...

How to detect TCP Client disconnect in Ruby

In order to check the client servers is alive at anytime, I use the long tcp connecting to deal with this. So is there any method to detect the long tcp connect from client servers? it's good to do with Ruby ...

Help: Shifting to ubuntu and opensource from Microsoft stack

Hi Guys, I love SO and have been using it for the last 2 years. I've never posted any questions on it (because I found most answers though SO's search). I have high hopes for this question. I have been a .NET developer for the last 7-8 years (ASP.NET, ASP.NET MVC etc) and now i want to learn something new, especially outside Wi...

Overloading association methods

Does anyone know if there is a way to overload an association accessor method and not the setter? For example class Bar has_many :users def users 'foo' end end a = Bar.new a.users # => 'foo' a.users << bob => [bob] Hope that makes sense. ...

Update a <div> with form selection

Hello, Again,quite new to Ruby on Rails and Ajax, both. I heard it is supposed to be quite easy to add Ajax stuff into the web sites, and since my forms are somewhat done, I thought I would give it a try. But there are some problems, unfortunately, that I could not really find the fitting documentation. I tried with the only method I f...

NetBeans + Ruby: Stop on All Errors

It might be obvious, but I started using NetBeans only recently. In Visual Studio one of my favorite debugging tools was "break on all errors", same in Firebug. But I can't find this option in NetBeans. What is the best way to break on Ruby error using NetBeans? ...

Is cucumber suitable for non-web project?

I want to develop a network system. It is not based on rails and has no html UI. Do I have to do BDD in this case? Does using Cucumber make sense? ...

Ruby on Rails and RVM: Problem including external gems in my Gemfile (Rails 3)

When I try to include an external gem in my Gemfile (e.g. from github), my RVM doesn't recognize the external gem. It keeps telling me to run "bundle install" even after already doing. For example, when I log into shell and do a "bundle check", I see that all "dependencies are satisfied" but in my browser, Passenger tells me that my gem...

What is a Ruby/Rails 'hook'?

I am editing some code, and I see the following: <% hook :login do %> <% form_tag user_session_path do %> <p> <%= label :user_session, :login, 'Email Address' %><br /> <%= text_field :user_session, 'login' %> </p> <p> <%= label :user_session, :password, 'Password' %><br /> <%= password_field :user_...

How to pass a Ruby hash key and value to a Rails FormHelper function?

In the controller, I'd like to do: @options = { :obj_id => @obj.id, :obj2_id => @obj2.id } And in the view: <%= remote_form_for(:model_object, :url => { :action => 'some_action' }) do |f| @options.each { |k, v| f.hidden_field(k, { :value => v }) } } %> The code above currently will just output the string values of ...

Sending objects values as IN statement in Rails

Hi, I'm working on a Newsfeed action. I have active friendships and i would like to find the posts only of those friendships to create the newsfeed. This is the code i currently have: @active_friendships = current_user.active_friendships @posts = Post.where({ :user_id => [5,8,16] }).order("created_at DESC") I don't know how to sen...