ruby-on-rails

How to get nice formatting in the Rails console

I want to get something like this to look nice: >> ProductColor.all => [#<ProductColor id: 1, name: "White", internal_name: "White", created_at: "2009-06-10 04:02:44", updated_at: "2009-06-10 04:02:44">, #<ProductColor id: 2, name: "Ivory", internal_name: "Ivory", created_at: "2009-06-10 04:02:44", updated_at: "2009-06-10 04:02:44">, #<...

Rails Photo Gallery Plugin for 3rd Party Hosting on Flickr or Picasa

I don't want to store photos on the server. I'd prefer to use picasa or flickr, etc. I'm wondering what solutions are popular and work well. I've found: http://code.google.com/p/picasaonrails/ http://code.google.com/p/loupe/ Has anyone tried these? Any alternative suggestions? Thanks all. ...

Catch-22: Rails db migration doesn't run when class constants make db calls

I have a class similar to the following: class FruitKinds < ActiveRecord::Base Apple = FruitKinds.find(:all).find { |fk| fk.fruit_name == :apple.to_s } # ... other fruits # no methods end Apple and other specific Fruits are commonly used as default values elsewhere in my application, so I want a handy means to refer to t...

More precise distance_of_time_in_words

distance_of_time_in_words is great, but sometimes it's not granular enough. I need a function that will report exact distances of time in words. E.g., 7:50AM to 10:10AM should be a distance of "2 hours and 20 minutes", not "about 2 hours" or whatever distance_of_time_in_words would do. My use case is reporting train schedules, and in p...

Is it possible to generate a longer hash value with string#crypt?

Two quick questions about ruby's string#crypt(salt) method. In the documentation it claims the salt should be two characters? I thought a salt could be anything I wanted, no? I am using a random value that is larger than two characters and it seems to work fine. Is this an error in the documentation or in my understanding of how this w...

Keep log of capistrano deployments

Is there a way to keep a log (either local or stored on a remote server) of every time a deployment is done via capistrano? It would be very useful to keep a record of what revision was running at any given time in the past. I know that the deployment process leaves behind the deployed files for the last 10 deployments in the releases ...

"Callbacks" in Linq-to-SQL/ASP.NET MVC

After using .NET for several years, I've spent the last few months in the far off land of Ruby on Rails. While I can clearly see where much of Microsoft's MVC framework got it's influence, one of the things that I find myself suddenly missing when development in .NET are the Rails Model callbacks. Specifically, you can add a callback t...

Doubt in Functional Testing

Hi Below is my functional test code def test_should_create_county assert_difference('County.count') do post :create, :county => {:name=>"myname",:description=>"mydesc",:region_id=>"3" } end assert_redirected_to county_path(assigns(:county)) end end And error message i got is 29) Failure: test_should_create_county(CountiesContro...

How do i work with two different databases in rails with active records?

I need 2 db connections in my rails model, is there a not so hackey way to do that? any links or search keywords would be great :) ...

updated acts_as_versioned_association

hi has anyone got a acts_as_versioned or acts_as_audited that supports the models associtions ? like the acts_as_versioned_association but this doesnt work in rails 2 + ? Also can you use globalize2 with any of these plugins ? Does anyone have any experience using versions and globalize2 ? thanks alot rick ...

tips for installing postgres for a rails project on a linux box

hi I want to use a postgres database for 2 rails projects and for some php blogs. Does anybody have tips for me, which pg gem I should install for ruby? I'm searching also for some general postgres config tips. I run Ubuntu 9.04 as Server. Maybe a (not outdated) good tutorial would be great :) thanks guys ...

How to monitor delayed_job with monit

Are there any examples on the web of how to monitor delayed_job with Monit? Everything I can find uses God, but I refuse to use God since long running processes in Ruby generally suck. (The most current post in the God mailing list? God Memory Usage Grows Steadily.) Update: delayed_job now comes with a sample monit config based on thi...

Rails refuses to load a session from the data sent by swfupload

I'm using swfupload's most recent version, 2.2.0 and rails 2.3.3. Having seen a number of statements to the effect that I would have to replace CGI::Session.initialize with a chunk of code to extract the session from key-value pairs injected into my form url, I incorporated the code segment into my environment.rb: require 'cgi' class C...

rails project help

hi i am trying to get my head around the best way to develop an app in ruby on rails i have a ducument creation system that for each document has multiple associations ie text docs, images, optional accessories etc. I have created this system now to do CRUD. The next thing i want to do is have each document able to be translated into...

Activate and Deactivate the Rails code hyperlink using JQuery

How to activate and Deactivate the Rails code hyperlink using JQuery for the following code <%= f.add_associated_link "Add another email address",:class => 'add' %> please suggest me to solve this major problem ...

bandwidth management with rails?

I was wondering if anyone knew of a way that you could manage bandwidth within a rails application in some way that isn't dependent on the web server. For example each account has a bandwidth limit. In and out bound traffic subtracts from the monthly allowance? ...

how to get client IP and Server IP using Rails

can any one please help how to get client IP and also server IP using Ruby on Rails ...

How to validate corrupt image file while uploading using Rails

How to validate corrupt image file while uploading using Rails if the corrupted jpg or png file (or change the extension of any other type of file to jpg) the system will have to show error during upload ...

Rails: How to display Umlauts / Special characters with ultrasphinx and aspell?

Hi, I'm using Ultrasphinx for fulltext search, combined with aspell to provide the user with corrections. When I use the german dictionary and enter any Umlaut (öäü) Ultrasphinx::Spell.correct(@search.query) always returns a correction, even when the word is spelled correctly. Also the Umlauts are replaced with ? in the console and ...

how to pass hash as radio button option

am passing the hash as radio button option .. like { 1=>["a", "b"], 2=>["c"], 3=>["a", "d", "f", "g"], 4=>["q"]} but for the first option am getting radio button, for other values am not getting it am getting like this 1--- o a b 2---- o c 3--- o a b c can anybody give some idea about, how to pass hash as radio button o...