ruby-on-rails

adding html to my RSS/Atom feed in Rails

The default rails XML builder escapes all html so something like: atom_feed do |feed| @stories.each do |story| feed.entry story do |entry| entry.title story.title entry.content "<b>foo</b>" end end end will produce the text: <b>foo</b> instead of: foo Is there any way to instruct the XML builder ...

in Rails : Retreive user input from a form that isn't associated with a Model, use the result within the controller.

Here's a simplified version of what I'm trying to do : Before any other actions are performed, present the user with a form to retrieve a string. Input the string, and then redirect to the default controller action (e.g. index). The string only needs to exist, no other validations are necessary. The string must be available (as an ins...

Building Ruby on Windows XP

Has anyone out there got a good set of instructions for building/compiling Ruby from source of windows XP ? ...

Backend Administration in rails

I'd like to build a real quick and dirty administrative backend for a rails app I have been attached to at the last minute. I've looked at activescaffold and streamlined and think they are both very attractive and they should be simple to get running but I don't quite understand how to set up either one as a backend admin page. They se...

Application Context in Rails

Rails comes with a handy session hash into which we can cram stuff to our heart's content. I would, however, like something like ASP's application context, which instead of sharing data only within a single session, will share it with all sessions in the same application. I'm writing a simple dashboard app, and would like to pull data ev...

Testing rendering of a given layout with RSpec & Rails

Is it possible to test the use of a given layout using RSpec with Rails, for example I'd like a matcher that does the following: response.should use_layout('my_layout_name') I found a use_layout matcher when Googling but it doesn't work as neither the response or controller seem to have a layout property that matcher was looking for. ...

Rails and Gmail SMTP, how to use a custom from address

I've got my Rails (2.1) app setup to send email via Gmail, however whenever I send an email no matter what I set the from address to in my ActionMailer the emails always come as if sent from my Gmail email address. Is this a security restriction they've put in place at Gmail to stop spammers using their SMTP? Note: I've tried both of th...

How do I test that a Rails Helper defines a method?

I am creating a Rails plugin and it is dynamically adding a method to a Helper. I just want to ensure that the method is added. How can I see if the Helper responds to the method name? ...

Rails ar_mailer fails to send emails

I've just switched an application to use ar_mailer and when I run ar_sendmail (after a long pause) I get the following error: Unhandled exception 530 5.7.0 Must issue a STARTTLS command first. h7sm16260325nfh.4 I am using Gmail SMTP to send the emails and I haven't changed any of the ActionMailer::Base.smtp_settings just installed ar_...

Uniq by object attribute in Ruby

What's the most elegant way to select out objects in an array that are unique with respect to one or more attributes? These objects are stored in ActiveRecord so using AR's methods would be fine too. ...

Not getting emails from ExceptionNotifier

I followed this tutorial on configuring the Rails plugin ExceptionNotifier. I know that I have ActionMailer configured correctly because I am getting mail from other forms. I even have local_addresses.clear set so that it should be delivering mail no matter what. I am using Apache with a mongrel_cluster running in the backend. What am...

Why should I use RSpec or shoulda with Rails?

I am setting up a rails app and I just finished making some unit tests and my friend said that apparently fixtures are no longer cool and people are now using RSpec or shoulda. I was wondering what the actual benefits are to use these other toolkits. Any information at all is appreciated. -fREW ...

What is the best way to store app specific configuration in rails?

I need to store app specific configuration in rails. But it has to be: reachable in any file (model, view, helpers and controllers environment specified (or not), that means each environment can overwrite the configs specified in environment.rb I've tried to use environment.rb and put something like USE_USER_APP = true that worked...

How do I save a model with this dynamically generated field?

I have a rails model that looks something like this: class Recipe < ActiveRecord::Base has_many :ingredients attr_accessor :ingredients_string attr_accessible :title, :directions, :ingredients, :ingredients_string before_save :set_ingredients def ingredients_string ingredients.join("\n") end private def...

Mod_rails and mongrel running on the same server?

I'm currently running mongrel clusters with monit watching over them for 8 Rails applications on one server. I'd like to move 7 of these applications to mod_rails, with one remaining on mongrel. The 7 smaller applications are low-volume, while the one I'd like to remain on mongrel is a high volume, app. As I understand it, this would b...

interval rails caching

I need to cache a single page. I've used ActionController's caches_page for this. But now, I'd like to expire AND regenerate it once in every 10 minutes. What are my options? later: I'd like to not use any external tools for this, like cron. The important point is interval-based expiry of the cache. ...

Best way to add tests to an existing Rails project?

I have a Rails project which I neglected to build tests for (for shame!) and the code base has gotten pretty large. A friend of mine said that RSpec was a pain to use unless you use it from the beginning. Is this true? What would make him say that? So, considering the available tests suites and the fact that the code base is already the...

What is the best way to return multiple tags from a Rails Helper?

I want to create a hidden field and create a link in one helper and then output both to my erb. <%= my_cool_helper "something", form %> Should out put the results of link_to "something", a_path form.hidden_field "something".tableize, :value => "something" What would the definition of the helper look like? The details of what link_t...

Combining Scriptaculous and JQuery in a Rails application

I've got the following situation A rails application that makes use of rjs / Scriptaculous to offer AJAX functionality Lot of nice javascript written using JQuery (for a separate application) I want to combine the two and use my JQuery based functionality in my Rails application, but I'm worried about JQuery and Scriptaculous clashin...

Where can I find some up to date information on OpenID authentication with rails?

The question says it all. I can't seem to find any recent rails tutorials or whatever to set up an OpenID authentication system. I found RestfulOpenIDAuthentication but it's so much older than the vanilla Restful Authentication and the docs don't even mention Rails 2 that I am pretty wary. Does anyone have any tips? I'd like to do wh...