ruby

Run rake tasks in sequence.

I have rake tasks which i want to run in proper sequence. I want to run one rake task which run other rake tasks in proper sequence. How may i do that? ...

Ruby On Rails: Testing deletes tables

Hi there! I'm creating an application in RoR and I'm implementing unit testing in all my models. When I run every test on his own (by running ruby test/unit/some_test.rb) all tests are successful. But when I run all tests together (by running rake test:units) some tables from both databases (development e test) are deleted. I'm using...

mongodb gridfs carrierwave or joint or other ?

i want to store all my assets in mongo gridfs. i was trying to get carrierwave setup with mongomapper and gridfs but seems carrierwave supports mongoid now instead. I need to be able to save different size versions / cropped versions of an image so thats why i was going to use carrierwave. Currently its set up to store on file ...

Problems with reflection within Rails

I have a Rails app representing a card game. There are several different types of card, and a few expansions for the game, each providing more cards. So I'm using a single cards table and STI, with each expansion having a models subdirectory and appropriately-named module. Like this: app/models - card.rb + base_game - foo.rb - cla...

Learning Ruby On Rails

I want to learn Ruby on Rails. I've done some work with various java frameworks but I can no longer ignore everyone RoR craze. I did some looking around and found that a lot of people recommend Agile Web Development with Rails as a good starting point. Would you agree? I was looking on the site for it (http://pragprog.com/titles/rail...

How to extract attribute name and value pair from xml using Nokogiri?

Example: <fruit name="mango"/> I want to get output as: name="mango" ...

What does == do in Ruby?

In Java, == is the strongest kind of equality (pointer equality): a == b always implies a.equals(b). However, in Ruby, == is weaker than .equals?: ruby-1.9.2-rc2 > 17 == 17.0 => true ruby-1.9.2-rc2 > 17.equal?(17.0) => false So, where can I learn more about ==? What kind of checks should I expect when I compare two objects with it?...

How do you install a Ruby on Rails apps on Windows/IIS?

I'm trying to get Redmine working on Windows/IIS 7. I've found several walkthroughs online, but none of them work on my Windows Server 2008 R2 box. I got a simple app (create app, no customization) to get as far as RoR error, but Redmine itself shows a 500 error (ruby.exe exited unexpectedly). I installed sqlite since some guides ment...

Creating a plist in Rails 3

Hi! I'm new to Rails and I'm trying to learn it using Rails 3 (RC). I have managed to use http://plist.rubyforge.org/ for supporting the output of plists. I would like to check with you guys to see if my approach is the right way to do it. Here goes: In the gemfile I added gem 'plist' In config/initializers/mime_types.rb I added Mime:...

What can a ruby gem do?

I'm working on something in ruby and trying to figure out if it can be turned into a gem. I can find documentation on how to make a gem and gem manuals, but I can't find anything that says, "here is what a gem can and cannot do." Let's say I created some code, which of the following can a gem do? 1) Use rails conventions like views and...

Dynamic methods in a Module?

I've got a module called AB. Right now it looks something like this: module AB extend self def some_method(hash) .... end .... end We use it like this: AB.some_method(:thing=>:whatever,:etc=>'you get the idea'). There are about a half-dozen strings that the user has to pass in that I'd like to turn into dynam...

What is this format in ruby?

In a book they showed me this declaration: friends = [ { first_name: "Emily", last_name: "Laskin" }, { first_name: "Nick", last_name: "Mauro" }, { first_name: "Mark", last_name: "Maxwell" } ] This doesn't look like a hash. And when I enter it in IRB i get an error. What is this format? ...

How do i get ruby to output an exception inside a thread?

When I spawn a thread with Thread.new{} it looks like any exception that happens in that thread never sees the light of day, and the app just quietly ignores it ...

Ruby accept argument via drag and drop onto rb script

I would like to have ruby open with dropped files as arguments. I running Win 7 Enterprise, Ruby 1.8.6 and have tried RubyDragAndDrop.dll, which I could not get installed. Any ideas? ...

Mechanize and NTLM Authentication

The following code generates a 401 => Net::HTTPUnauthorized error. From the log: response-header: x-powered-by => ASP.NET response-header: content-type => text/html response-header: www-authenticate => Negotiate, NTLM response-header: date => Mon, 02 Aug 2010 19:48:17 GMT response-header: server => Microsoft-IIS/6.0 response...

Error Installing ruby gem for PostgreSQL

I am trying to configure a rails server to use PostgreSQL, but getting stuck when installing the postgres gem. I have installed PostgreSQL successfully on the machine (and can use it for other applications) but am getting an error when attempting to install the ruby gem for it. I do: sudo gem install postgres And get the following outp...

Read only mode for Ruby on Rails application

I have an interactive Ruby on Rails application which I would like to put into a "read only mode" during certain times. This will allow users to read the data they need but block them from actions that write to the database. One way to do this would be to have a true/false variable located in the database that was checked before any ...

Rails3 + Datamapper - concurrent database connections

Is it possible to use concurrent databases in one rails application? With AR I can use establish_connection method inside a model. Is it possible with datamapper? ...

Actionmailer not delivering mail, with rails 3

I am trying to make an application, that sends an email when user registers. i put in the smtp settings for gmail in the config/application.rb file and the mail function looks like mail(:to => "[email protected]", :subject => "Mail!", :from => "[email protected]", :content_type => "text/html") now when i see the logs, i see that it says mail ha...

Sinatra and Bundler

Hi, I'm trying to get Bundler setup so I can deploy my Sintra a server with all the correct gems. I've created my Gemfile source :gemcutter gem 'sinatra', '1.0' gem "nokogiri", "1.4.2" gem "rack", "1.1.0" gem "dm-core", "1.0.0" gem "dm-migrations", "1.0.0" gem "dm-sqlite-adapter", "1.0.0" gem "pony", "1.0" Next I created a Confi...