ruby

has_attribute? problem

I have an HTML document and I need to examine, whether some attribute is presented in element in question Suppose, that the attribute is not presented. When i say: elem.has_attribute? "data-attr" it returns nil instead of "false". When i say: elem["data-attr"].nil? it returns "true", that is what i need. But, when i say: !elem...

Ruby NLP Libraries

Hi, Does anyone know of any good NLP frameorks for ruby? I am considering using the Java open-nlp librabrary http://opennlp.sourceforge.net/ via JRuby. I am reluctant to go down the JRuby route for a few reasons and mainly because I have no Java background. Are there any ruby frameworks or should I go down the JRuby route with open-n...

Issue with precision of Ruby math operations

Do you know how to fix the following issue with math precision? p RUBY_VERSION # => "1.9.1" p 0.1%1 # => 0.1 p 1.1%1 # => 0.1 p 90.0%1 # => 0.0 p 90.1%1 # => 0.0999999999999943 p 900.1%1 # => 0.100000000000023 p RUBY_VERSION # => "1.9.2" p 0.1%1 # => 0.1 p 1.1%1 # => 0.10000000000000009 p 90.0%1 # => 0.0 p 90.1%1 # => 0.099999999999994...

how to write proper method?

class Mycompute def initialize(str) @str=str end def values @@result=@str end def up @@result.upcase end end irb(main):012:0> Mycompute.new("Abc").values => "Abc" irb(main):013:0> irb(main):014:0* Mycompute.new("Abc").up => "ABC" irb(main):015:0> Mycompute.new("Abc").values.up NoMethodError: undefined me...

How can I create SSH public/private key pairs in ruby and store them in the Db.

I'm writing a ruby on rails service that will conect to various servers via SSH. I want to generate the public/rivate key and store them in the database. Then the user will be able to view the public key and add it to there key authentication for SSH on their server. The my service will contact the servers via Net::SSH and present the ...

is there any hack to get around jruby( on rails)'s being so slow to start?

Possible Duplicate: How to improve jRuby load time? When developing a site using jruby on rails I find it quite annoying that every time I invoke jrake db:migrate or rails g migration I have to wait a few seconds for the java engine to start... $ time rails -v Rails 3.0.0 real 0m6.947s user 0m10.590s sys 0m0.230s ...

activemq and delay message deliver on ruby

I am already using ActiveMQ in my project. Now I need delay message delivering. AcitveMQ supports this feature (http://activemq.apache.org/delay-and-schedule-message-delivery.html), but as far as I understand this feature supported by JMS clients only. How could I use this feature with ruby? ...

Rails: Make a div element visible/invisible with onchange after changing a collection_select field

I have a collection_select field, and I want to make a div visible or invisible after changing it, depending on the new value. I have the below code for the collection_select field, there is a JS function change_div_visibility which currently accepts a div name but I also want to pass in the collection_select value. How can I also se...

What is the best way to set up a form to get a temp var?

I am making a photo upload form. Before they begin, they have two choices. They can create a new gallery, OR they can choose from an existing gallery. I was thinking the best way to lay this out would be two have two forms. One for the create one that would take them to the create page. That's easy, and practically done. But the second...

How can I set flag CLIENT_MULTI_STATEMENTS for mysql2 ruby gem?

Or another way to run multiple queries in one function call in mysql2 gem? ...

because ruby is a dynamic lang, is it easy to create a plugin architecture in a rails app?

Say in a action, I want to create points in the code where someone can hook into, without having to go into the controller action and edit my code. Is this possible? I guess they would have to hook into my code at some point when the application starts? I know wordpress has a plugin arch with hooks, wondering if the same can be done i...

Rails: Pass value of a field in a form to a javascript function

Not sure why this is not working... I have a collection_set as below <%= collection_select(:entry, :entry_status_id, EntStatus.find_all_draft_or_edit, :status, :en_desc, {}, { :onchange => "change_editor_select_visibility('entry_set_editor', this.value)" }) %> When I load the form, I want to set visibility on another div based on the...

Ruby method interception

I want to intercept method calls on a ruby-class and being able to do something before and after the actual execution of the method. I tried the following code, but get the error: MethodInterception.rb:16:in before_filter': (eval):2:inalias_method': undefined method say_hello' for classHomeWork' (NameError) from (eval):...

How does rails pass objects to the view?

If an action looks like: def show @post = Post.find(params[:id]) end I can then do: <%= @post.title %> How does it pass the object to the view? Since my action has only one line, what programming technique or pattern is used to take the @post object and pass it to the view (template) page? I know it assumes the view will be the...

Sleep will stop Nginx since it's an event-based server?

I think if you have setTimeout=1 then the node server will be unavailable for all requests in 1 second since it's event-based, non-threaded web server (correct me if I'm wrong). I've heard that Nginx is also an event-based web server. Doesn't that mean that if I have sleep 1 then it would be halted for all requests in 1 second? ...

Identifying all the nouns in a string with RoR

I need a helper that can identify all the nouns on a string. If the given string is I really enjoy eating tomatoes I should have, as result really, enjoy, and tomatoes If there is a way that I can also idetify the verbs, should be great! ...

Model Using Modules in Rails Application

I have a model that requires loading external data from an auxiliary source. A number of web services exist that my model can fetch the data from (swappable), but I don't want to create code that will make it difficult to change services (costs significantly differ based on variable and fixed usage and it is likely changing will be requi...

Migrating from Rails 2 to Rails 3

What resources are out there (free or paid) that help walk you through the process of migrating a Ruby on Rails 2 application to Rails 3? I've seen some blog posts (some of which seem out of date) and an eBook for sale somewhere on the RoR website, but what can you recommend as an accurate and complete explanation of what changed from ve...

How to set up a proper select form..

I am trying to draw the end result being that @gallery = whatever i choose in my select - form_for :gallery do |f| .grid_6.hr_dots.clear .exist_gal .grid_5 %label 2. Or add to an existing Gallery .clear .grid_4 = select @gallery, :gallery, options_for_select(@galleries.collect { |g...

LinkedIn API for Company Directory

I'm trying to use the LinkedIn API to search for companies, not users. I specifically don't want users - only companies. I had a look at the LinkedIn API Documentation (RTFM and all that), but as far as I can tell it's not supported. There are 2 posts on the forum which pretty much says this outright - here and here I'm basically jus...