ruby-on-rails

Rails import from Excel issue

We are using Ruby on Rails code to import the data from an Excel sheet, we use an alert where it asks whether we upload the data and append to existing data (MySQL database) and display it in a grid designed in Flex 3, or replace the old data with new data. But we are getting this error: Error in Importing excel files Open OLE error cod...

Ruby on Rails pattern for setting class defaults and allowing an override on subclasses

Basically I want to implement a simple Rails extension to define the seriousness of methods in my controller so that I can restrict usage of them appropriately. For example I'd define the default restful actions as so in an abstract superclass: view_methods :index, :show edit_methods :new, :create, :edit, :update destroy_methods :destro...

Rails /lib modules and

I am writing a custom wrapper for open_flash_chart plugin. It's placed in /lib and load it as a module in ApplicationController. However, I have some Class hierarchy or smth problem. From any controller I can access open_flash_chart functions as OpenFlashChart, Line etc However, in a class in a /lib module, it doesnt work! Any ideas?...

Concurrent Net::HTTP.get to same domain

As part of my Ruby on Rails application, I need to perform several (a few dozen) web requests to a foreign web server -- all on the same domain. I am aware of the two requests per domain throttle on Windows and know how to adjust that, but this application is running on CentOS and I was not expecting to run into this same issue, but I se...

Put an OpenID and Google Account Login in a Rails Project

Hello, I'm starting in the Rails world and i want to know how to put an login system like that here in Stack Overflow uses. Thanks, and remember that i'm starting, and if you can post a link to a very good tutorial, is very nice. ...

ruby Open URL and rescue

Hello, I would like to check if a few URL's exst on my old website and collect URLS that returns 404. @paintings = Painting.find(:all) @paintings.each do |painting| open("http://www.mydomain.com/" + painting.user.username.downcase + "/" + painting.permalink) rescue OpenURI::HTTPError @failure += painting.permalink else ...

What steps do you take to undo mistakes in Rails development?

A single Rails command can make lots of changes in an app - creating files and migrations, adding routes, etc. Undoing the damage of a mistake could be tricky for a beginner. For example, say you generate some scaffolding, run the migration, and then realize your scaffolding command should have been singular (ruby script/generate scaffo...

Simulate loading on localhost

I have a site which uses AJAX and preloaders. Now I would like to see the impact of these preoloaders before deploying the site online. The "problem" is that localhost doesn't have loading time and the response is immediate, so that I can't see my preloaders. How can I simulate loading or limited bandwidth (with Firefox, Rails or whate...

Is there a .NET equivalent for Groovy and Grails or Ruby on Rails?

Recently I've been playing a bit with Groovy and Grails and I have to say I'm nothing but impressed by the simplicity and productivity this framework could offer. In the past I've also greeted the world via Ruby on Rails and what not, having that very same feeling so it's pretty much obvious that when it comes to web apps, DRY KISS is d...

Will Ruby on Rails/Grails ever catch on in the enterprise?

My question is related to "Is Ruby on Rails ready for the Enterprise?" My question is not about IF Ruby on Rails/Grails is ready for the enterprise - my question is will they ever catch on in the enterprise? J2EE applications have such a strong foothold right now and a lot of investment from the giants (IBM, Oracle, etc) and those gian...

require 'rubygems' not working

when I type irb> require 'rubygems' it returns false. I have many gems in my rails app that are obviously working - rake, activerecord, etc. What could be going wrong here? thanks. Ruby 1.8.6. Rails 1.2.6 ...

Nil object on after_destroy

I have a method which updates a count of dependent objects for a parent class whenever a dependent is created or destroyed. This generally works, but for some reason when a parent is deleted by a third class with :dependent => :destroy, I get a nil error for the parent object when the count method is called and thus nothing gets deleted...

How to combine ActiveRecord objects?

I'm wondering if there's an efficient way to combine the results of multiple ActiveRecord objects in Rails. For example, I might make three individual calls to three individual tables, and I want the results combined, and sorted by a common column. Here's a super basic code example that will hopefully make my question easier to understa...

Problem with XML and HTTParty

Hi! I've just started using HTTParty, and i've encountered a problem in the way it builds the Hash from the XML replied by the server. If i setup the following Builder template on the server: xml.thunt :sendSubscriptionResult, :"xmlns:thunt" => "http://example.com/thunt", :status => @status everything works well, i.e. the Hash built...

Changing the column name of a rails object

What if I want to refer to a column of an ActiveRecord object by a different name? for example, I might call: @posts = Posts.find(:all, :select => "created_on") But instead of referring to @posts["created_on"], I'd like to refer to it as @posts["date"]. What would you recommend? Thanks! ...

Support for IMAP IDLE in ruby

Ok, I have been suck on it for hours. I thought net/imap.rb with ruby 1.9 supported the idle command, but not yet. Can anyone help me in implementing that? From here, I though this would work: class Net::IMAP def idle cmd = "IDLE" synchronize do tag = generate_tag put_string(tag + " " + cmd) put_string(CRLF)...

Rails and XML

Hi So I have a function that outputs an xml string that goes something like <expensesAC> <cashflow> <month>6</month> <cash>300</cash> <projected>null</projected> </cashflow> <cashflow> <month>6</month> <cash>300</cash> <projected>null</projected> </cashflow> <cashflow> <month>6</month> <cash>300...

Rails Recaptcha plugin always returns false

I'm using the rails recaptcha plugin found here: http://github.com/ambethia/recaptcha/tree/master I have signed up for an account on recaptcha.com, obtained a public & private key, and the site is configured with a global key (for now). In config/environment.rb I setup the environment variables: ENV['RECAPTCHA_PUBLIC_KEY'] = 'xxxxxxxx...

How to execute ActionView, ERB::Util from ./script/console in Rails 2.0.5

I develop it in Ruby on Rails 2.0.5 now. Can I execute link_to method and the url_escape method use in /script/console? ...

How do I get rspec / autotest going on a rails project?

What's the best practice for getting RSpec / Autotest going on a Rails project? I googled some stuff but it feels like it may be out of date. ...