ruby-on-rails

What kind of ruby method call is Array(x)

What is the meaning, and where is the Ruby documentation for the syntax of: Array(phrases) which I found browsing the Rails source here: # File actionpack/lib/action_view/helpers/text_helper.rb, line 109 ... 119: match = Array(phrases).map { |p| Regexp.escape(p) }.join('|') I thought that Array.new would normally be used...

Need help setting up scaffolding for this situation

I asked a question earlier, and got an excellent response, but, being a newbie to Rails and still getting the basics down, I need someone to show me how to set up some scaffolding for the situation that Hates_ was nice enough to outline for me. I've set up my application and whatnot, but I basically want to have, for example purposes: ...

Rails: Reconstructing ActiveRecord Objects from a JSON array.

I have a JSON array with ActiveRecord objects. These objects can be reconstructed using the from_json method, which every AR object has. However with from_json it's only possible to reconstruct one single object. To process an array, I could of course just extract substrings from the JSON array and create every object from it's own subs...

Rails form validation

I have a Rails app that lets a user construct a database query by filling out an extensive form. I wondered the best practice for checking form parameters in Rails. Previously, I have had my results method (the one to which the form submits) do the following: if params[:name] && !params[:name].blank? @name = params[:name] else fla...

constant values in Rails

I have some data that I want to store somewhere in my Rails app because I use it for generating form fields, checking a submitted form to ensure its values are valid, etc. Basically, I want the data in one location because I make use of it in several places. Previously, I was defining an initialize method in my controller and initializ...

jRails vs. Prototype

I am not trying to make this a preference question, I am really wondering what people's experiences are with using jQuery and Rails or jRails for development. Most rails users including myself up to now have been using Prototype. However, I am mixing in a lot of jQuery plugins since they are so easy to use and extend. I am now thinkin...

Rails - setting multiple layouts for a multipart email with mailer templates

Hi there, So Rails 2.2 added mailer layouts, which is great, except that I can't figure out how to make them work when I'm sending a multipart email..it's wrapping my mail content with the same layout for both the text/plain version and the text/html version. What I want is to wrap my layout around either only the text/html version, or...

ROR: To scaffold or not?

I love scaffolding and it extremely helpful for prototyping. But Should we use scaffolding for developing application as such? ...

Problem with self-referential has_many :through associations in Rails

I was reading about self-referential has_many :through data situations today, because I'm trying to build a Rails application that uses them. I found this example situation on the Internet, and I have a question about it. Let me post this example code from this guy's blog: create_table :animals do |t| t.string :species end create_tabl...

Aptana RadRails?

I've been using a text editor for my rails app for a while and I have a workflow that I am happy with for my existing app. However, I am about to be starting a new app and it appears that Aptana RadRails is sufficiently developed and stable enough for use. (The last time I tried it it was in beta and wasn't quite fully baked.) So my qu...

What is the best approach for building an iphone client for a rails app?

I have a fairly standard rails app and would like to be able to access the basic CRUD (Create, Update, Delete) operations as well as queries I have added, from an iPhone app. Rails provides the REST API for these operations more or less out of the box. What is the best approach to deal with the REST/XML part on the iphone, and are ther...

How do you handle Rail's flash with Ajax requests?

I'm pretty happy with the solution that I came up with. Basically, I have a helper method that reloads the flash inline, and then I have an after_filter that clear out the flash if the request is xhr. Does anyone have a simpler solution than that? ...

Any thoughts on RightScale and Scalr for dynamic Ec2 instance managment

Hi Am looking for a cost effective tool for managing an web app on Ec2. Rightscale seems to the big dog and charges for it. Scalr looks like a more cost effective solution but hard to find out any real customer experiences.. The key aspects I'm looking for is a load balancer (http and https) and a way to automatically bring online add...

Basic Rails question: manually inserting a row into a database table

I'm learning Rails and it's going well so far. My biggest question at the moment is: how do I go about manually inserting a row into my database? I've got the scaffolding in place for creating rows of DataTypeOne, but I want a row for DataTypeTwo to be created when the form for DataTypeOne is submitted (and have it reference the id of Da...

Is there a graphical widget for selecting timezone in Rails?

I know there's a dropdown selector for timezone, but I was hoping for a map where the user can click on a region and have that set a hidden field for what time zone it is. ...

Is there a way to get the UTC offset for a timezone based on a geocoded location?

This would be useful when I have a user's address or zipcode, and used that to find their timezone so they don't have to enter it in a separate field. ...

What is the best way to test mailing list software?

I recently wrote mailing list software in Ruby On Rails. I would like to get some expert advice on the best way to test it. For example, it would be cool if I could write a script generate 10,000 email addresses, use the software to send an email to those 10,000 addresses, and then write a script to make sure the emails got through. I...

What is a good tutorial or reusable resource for 'web 2.0' design?

I'm looking for a tutorial or some reusable resources that I can use to give my application a more modern look and feel. For want of a better description, I'm aiming for a simple and uncluttered web2.0 / ajaxy look. edit: emphasis on simple and uncluttered - something stripped down and functional Ideally I am looking for something quick...

Rails AJAX: My partial needs a FormBuilder instance

So I've got a form in my Rails app which uses a custom FormBuilder to give me some custom field tags <% form_for :staff_member, @staff_member, :builder => MyFormBuilder do |f| %> [...] <%= render :partial => "staff_members/forms/personal_details", :locals => {:f => f, :skill_groups => @skill_groups, :staff_member => @staff_member} %...

C# Extension Methods - How far is too far?

Rails introduced some core extensions to Ruby like 3.days.from_now which returns, as you'd expect a date three days in the future. With extension methods in C# we can now do something similar: static class Extensions { public static TimeSpan Days(this int i) { return new TimeSpan(i, 0, 0, 0, 0); } public static ...