ruby

How do I find all the records regardless of case..

What can i do you find a case insensitive search >> Band.find_by_name("metallica") => nil >> Band.find_by_name("Metallica") => #<Band id: 3, name: "Metallica", created_at: "2010-10-03 01:17:24", updated_at: "2010-10-03 01:17:24", user_id: "4"> I need to find the record in both cases...any suggestions? ...

Create a website that lets users create a website?

I have always written websites that interact with the endusers directly. Now I want to create a website that lets users create their own websites - from scratch. Almost like Drupal online, I provide all the unit blocks for them to use to build their own website. They just drag and drop text fields, buttons, (div) containers etc. I hav...

Books for Ruby On Rails With Facebook Platform!

Hey guys! do you know good books for Ruby On Rails With Facebook Platform. please suggest some good books for Ruby On Rails With Facebook Platform! ...

ImageScience for Windows on Ruby 1.9

Has anyone have any success installing ImageScience on Ruby 1.9 for Windows? Unfortunately, I am currently using Ruby 1.8 Windows for my development. I want to upgrade to Ruby 1.9 for the performance improvement. I was able to install almost all of the gems, but I haven't had any luck with ImageScience. Rob Anderton had put in useful i...

how to use youtube-g ruby gem?

Hi all, new to rails and trying to get youtube-g to work... I am having a difficult time passing a users search from the form_tag to the controller.. for example: user lands on page, enters - tiger videos - in text_field_tag controller takes - tiger videos - and searches user lands on another page displaying the results... user lands ...

Abnormal termination running an RSpec/Watir script

I am using Ruby 1.8.6, Watir 1.6.6, and RSpec 1.3.0. When I run the following script, it "terminates" (term given in EclipsePDT IDE) but no error is listed. Same when I run it from the c-prompt on windows, except no "terminate". The browser never opens. Anybody got a clue? It runs OK if I take off the describe, it, and end lines. descri...

Handle skype message using Ruby

Is there any library that allows to handle Skype messages using Ruby? ...

Handle google talk message using Ruby

Is there any library that allows to handle google talk messages using Ruby? ...

MYSQL wrong time.now

Hi there, We got a Rails 3 Server based on Ruby 1.9.2 running on a MYSQL DB and Problems with the time.now and time.zone.now setting. For better explaination we assuse its 13:00 UTC right now. Ubuntu Systemtime is set to 15:00 UTC +02:00 (Thats CEST (Central European Summertime) and is correct for our Timezone). The Rails time (time....

How to save something to the database after failed ActiveRecord validations?

Basically what I want to do is to log an action on MyModel in the table of MyModelLog. Here's some pseudo code: class MyModel < ActiveRecord::Base validate :something def something # test errors.add(:data, "bug!!") end end I also have a model looking like this: class MyModelLog < ActiveRecord::Base def self.log_so...

Is there a library that integrates R into ruby?

I recently investigate a integration between ruby and R on Windows 7. So far, rinruby hangs (on my Windows7 machine) when I run a script. Now I learn from this post that rsruby does not work on Windows at all. Does anybody know a library that would work? ...

In Rails 2 yielding a block in a helper a method renders partial?

Rails 2.2.2 _competition.html.erb <p>This is packed</p> <% pack do %> // some javascript <% end %> competitions_helper.rb def pack(&block) yield + 'PACKED' end However 'PACKED' does not get appended to my javascript string, its as if pack do has no effect. It seems like there is some oddness going off with context of the blocks ...

Ruby: Split binary data

I want to split data to chunks of let's say 8154 byte: data = Zlib::Deflate.deflate(some_very_long_string) What would be the best way to do that? I tried to use this: chunks = data.scan /.{1,8154}/ ...but data was lost! data had a size of 11682, but when looping through every chunk and summing up the size I ended up with a total s...

Ruby use case for nil, equivalent to Python None or JavaScript undefined

How does Ruby's nil manifest in code? For example, in Python you might use None for a default argument when it refers to another argument, but in Ruby you can refer to other arguments in the arg list (see this question). In JS, undefined pops up even more because you can't specify default arguments at all. Can you give an example of how ...

What alternatives to IRB are there?

In the python world, there are a number of alternative python interpreters that add cool additional features. One particularly useful example is bpython, which adds dynamic syntax highlighting, automatically pulls documentation, and displays live autocomplete information. In the Ruby world, I have yet to uncover any projects which add to...

Grouping a ruby array

I have a ruby array > list = Request.find_all_by_artist("Metallica").map(&:song) => ["Nothing else Matters", "Enter sandman", "Enter Sandman", "Master of Puppets", "Master of Puppets", "Master of Puppets"] and i want a list with the count like this Nothing Else Matters => 1 Enter sandman => 2 Master of Puppets => 3 So ideally i wan...

unix utility that reads files into memory?

I am using Ruby's net-ssh library to remotely execute shell commands. I would like to read a few files into memory rather than simply transfer them via SCP/SFTP. Can can I do this? ...

Does anyone know of a tutorial for datamapper + sqlite3 with ruby?

I'm a newbie to programming & ruby (as well as datamapper & sqlite). I'm trying to figure out how to use all three but can't find any tutorials for beginners. Please let me know of tutorials or books. Thanks. ...

"Wrong number of arguments (1 for 0)" in the "create" action

I've got a functional test that errors on the following method, saying that the first "Quality.create!(..." statement has too many arguments, which doesn't make any sense to me at all. Running Ruby 1.8, Rails 2.3.5 def reset_quality_lut Quality.delete_all Quality.create!(:value => 1, :name => "Scrap", :extended_na...

Nokogiri and XML Formatting When Inserting Tags

I'd like to use Nokogiri to insert nodes into an XML document. Nokogiri uses the Nokogiri::XML::Builder class to insert or create new XML. If I create XML using the new method, I'm able to create nice, formatted XML: builder = Nokogiri::XML::Builder.new do |xml| xml.product { xml.test "hi" } end puts builder outputs the foll...