ruby

How do I change the icon of my Shoes App?

I was wondering if it was possible to change the my Shoes app's icon? I imagine its style-oriented, but I haven't been able to find anything on it. Is this possible? ...

How to output names of ruby unit tests

I have a unit test (example is modified Test::Unit documentation) require 'test/unit' class TC_MyTest < Test::Unit::TestCase def test_something assert(true) end end When I execute it, I get: Loaded suite C:/test Started . Finished in 0.0 seconds. 1 tests, 1 assertions, 0 failures, 0 errors I would like to get something li...

How would you build this daily class schedule?

What I want to do is very simple but I'm trying to find the best or most elegant way to do this. The Rails application I'm building now will have a schedule of daily classes. For each class the fields relevant to this question are: Day of the week Starting time Ending time A single entry could be something such as: day of week: Wed...

method redefined warning while running Merb 0.9.3

I get numerous "method redefined" warnings while running an application under Merb 0.9.3. Of course, I get this only when I run my script using the ruby -w option. Is there any way to get rid of the methods getting redefined (repeated loading of files) again and again? Has this been resolved in Merb 1? ...

Elegantly selecting attributes from has_many :through join models in Rails

I'm wondering what the easiest/most elegant way of selecting attributes from join models in has_many :through associations is. Lets say we have Items, Catalogs, and CatalogItems with the following Item class: class Item < ActiveRecord::Base has_many :catalog_items has_many :catalogs, :through => :catalog_items end Additio...

What's the best way to compile Ruby from source on 64-bit RedHat Linux

On RedHat Enterprise Linux 5 the latest Ruby version available via RPM is 1.8.5. My Rails app requires 1.8.6 or above so I need to compile Ruby from source. I have tried the following to build it and it seems to build ok, but then I'm seeing gcc compilation errors when trying to run a plug-in which requires RubyInline. There seems to ...

XML File as database?

Is it possible to use single XML file for Ruby on Rails as an ActiveRecord database? ...

Recommendations for a language for a non-professional beginner

Duplicate See also: http://stackoverflow.com/questions/419959/language-for-non-programmers-to-start-learning-programming http://stackoverflow.com/questions/190957/what-language-is-best-for-a-beginner-to-learn http://stackoverflow.com/questions/4769/easiest-language-to-start-with I'm for advice on learning a new programming language....

Rails: FasterCSV - Unique Occurences

I have my CSV file imported as such: records = FasterCSV.read(path, :headers => true, :header_converters => :symbol) How can I get the unique occurences of my data? For instance, here some sample data: ID,Timestamp test,2008.12.03.20.26.32 test,2008.12.03.20.26.38 test,2008.12.03.20.26.41 test,2008.12.03.20.26.42 test,2008.12.03.20....

In Rails, how do you use RESTful controllers with Haml?

I'm getting started on figuring out how to use RESTful design. I have this action: # GET /feedback_messages # GET /feedback_messages.xml def index page = params[:page] page ||= 1 @feedback_messages = FeedbackMessage.paginate( :all, :page => page, :per_page => 20, :order => 'updated_at' ) respond_to do |format|...

Ruby on Rails: hash.each {} issues

Here is my code: records_hash = records[:id].inject({}) { |result,h| if result.has_key?(h) result[h] += 1 else result[h] = 1 end result } @test2 = records_hash.each{|key,value| puts "#{key} is #{value}"} My output should look like this: bozo is 3 bubba is 4 bonker is 5 But it renders on the page (<%= @test2 %>) as ...

Weird Behavior when using between? method for dates

Open up a Rails console and enter this: 2.weeks.ago.between? 2.weeks.ago, 1.week.ago Did it give you true or false? No really, try it a few more times and it will give you different answers. Now, I'm thinking that because we're comparing 2.weeks.ago with 2.weeks.ago, the time between evaluating the two statements is causing this beha...

Ruby on Rails: Common pitfalls/gotchas

There is a similar question about Ruby in general but I am soon to be starting out using Ruby on Rails to develop a website or two. What are the common pitfalls/gotchas that are specific to Rails. ...

Ruby: Math functions for Time Values

How do I add/subtract/etc. time values in Ruby? For example, how would I add the following times? 00:00:59 + 00:01:43 + 00:20:15 = ? ...

Rails: how do you access RESTful helpers?

I'm trying to work through this guide to Rails routing, but I got stuck in section 3.3: Creating a RESTful route will also make available a pile of helpers within your application and then they list some helpers like photos_url, photos_path, etc. My questions: Where can I find the complete list of helpers that is "made available?...

Mongrel hangs

Hi all, I'm running into a problem in a Rails application. After some hours, the application seems to start hanging, and I wasn't able to find where the problem was. There was nothing relevant in the log files, but when I tried to get the url from a browser nothing happened (like mongrel accept the request but wasn't able to respond). ...

How to pass a flexible number of ids into a controller in Rails?

I'd like to display a comparison page so user can compare the properties of several objects in my database. Any number of objects can be compared. I'd also like it to be bookmarkable (so a 'get'). How should I structure my URL / route for the controller? Something like /foo_compare/1_5_22 where I split the ids into 1, 5 and 22 in the ...

Using Ruby Gem DBI

Hi, I want to access MySQL through ruby on a shared linux server. I figure I need to use the DBI module, but I can't seem to access it. I installed it as follows: gem install -r dbi It couldn't install it in the normal location, since I'm on a shared server and don't have permission: WARNING: Installing to ~/.gem since /usr/lib/rub...

Open Firefox browser with Ruby automation script

Hello! How is it possible to open FireFox browser by Ruby(for automation script)? I use @browser = RSpecSeleniumHelper.connect_browser('/admin/', '*firefox'), but it doesn't work. ...

How do I "copy unless later version exists" in Capistrano?

I want to protect my database.yml file by keeping it out of version control. Thus, I have two tasks in my Capistrano deploy recipe: task :copy_db_config do # copy local config file if it exists and is more # recent than the remote one end task :symlink_db_config do run "ln -nfs #{shared_path}/config/database.yml #{release_path}/...