ruby-on-rails

Rails - Creating temp files in a portable way

My rails application runs on a Ubuntu server machine. I need to create temporary files in order to "feed" them to a second, independent app (I'll be using rake tasks for this, in case this information is needed) My question is: what is the best way of creating temporary fields on a rails application? Since I'm in ubuntu, I could creat...

Machinist vs FactoryGirl - pros and cons

Hi, I'm working with factory_girl, but looking at the machinist gem. Could you tell me please - what are the pros and cons of migrating to machinist? Have you compared those libs? ...

Need help modifying multiple models example from advanced rails recipes book

I'm developing a simple rails app for my own use for learning purposes and I'm trying to handle 2 models in 1 form. I've followed the example in chapter 13 of Advanced Rails Recipes and have got it working with a few simple modifications for my own purposes. The 2 models I have are Invoice and InvoicePhoneNumber. Each Invoice can have s...

How rspec works with rails3 for integration-tests?

What I'm trying to ahieve is to do integration tests with webrat in rails3 like Yehuda does with test-unit in http://pivotallabs.com/talks/76-extending-rails-3 minute 34. an example: describe SomeApp it "should show the index page" visit "/" body.should =~ /hello world/ end end Does someone knows a way to do it? ...

Multiple file upload (even folder)

I'm looking for an easy to use (free) "module" that can upload multiple files / folders. It must: Support image files be user-friendly be customizable It may be written in: RoR (Ruby On Rails) Java Flash Thanks in advance. ...

Multiple submit buttons with ajax

First of all, I'm new at Ruby on Rails, so if there's a better practice than what I'm doing, please let me know. What I'd like to do is to have multiple ajax submit buttons to perform different actions for a list of items with check boxes. So, when I select as many check boxes as I want, then I can choose what to do with them. I could ...

Two-part Rails layouts

My web pages consist of two parts, let's say top and bottom (except header and footer -- those are consistent across pages). What is the best practice to dynamically generate those parts depending on the action? One approach I have come up with is to have view for the top and partial for the bottom; in the layout call yield for the top ...

How to simulate the effect in stackoverflow on RoR?

I want to make a notification like this : it is only a flash[:notice] with some CSS trick in RoR? or it there any other trick on this? ...

Rails CanCan Auth Problem

I am using the CanCan authorization plugin (http://github.com/ryanb/cancan) for my application and it has worked great so far. I had it set like the following: class Ability include CanCan::Ability def initialize(user) user ||= User.new # guest user if user.role == "admin" can :manage, :all else can :r...

Executing large numbers of asynchronous IO-bound operations in Rails

I'm working on a Rails application that periodically needs to perform large numbers of IO-bound operations. These operations can be performed asynchronously. For example, once per day, for each user, the system needs to query Salesforce.com to fetch the user's current list of accounts (companies) that he's tracking. This results in hu...

convert rails plugin with rake tasks and capistrano recipes into gem

I want to convert rails plugin into gem. Is there any way to make gem to auto add rake tasks and capistrano recipes when mentioned in environment.rb using config.gem command? ...

How to change my parameter format?

Here is my Ruby Code: <%form_tag orders_path, :method => 'get' do%> From <%= date_select ("from", "", :start_year => 2010, :order => [:day, :month, :year])%> To <%= date_select ("to", "", :start_year => 2010, :or...

Transfer values from one selection box to another

I need to populate the first box with the items from a db table. Users would choose from the first box, and either drag value(items) to the second for selection, or would select items, and then click a button to move them over to the 2nd box. After that I need to update the db with the selected values/items. ...

ActiveResource NameError calling a WCF Service

Lately I've been working on validating an architectural design idea using Rails ActiveResource as a client and a WCF restful service as a server. I have the WCF service running on Windows Vista in a bootcamp partition on a Macintosh hosted in VMWare Fusion (self hosted mode). When I call the service from the Mac in a browser, I do indeed...

Is there any built-in method in RoR to fill zero for integer?

If I want "00001" instead of "1", apart from writing my own filling zero method, is there any built in method can help me fill in zero for the integer? ...

Javascript function in response to JQuery AJAX post fails in Rails...

I have finally got a JQuery lightbox solution to work in IE and with AJAX form posts with one exception. Here's what I'm trying to do: User clicks checkboxes to select users to send message to. (index.haml) User clicks submit, which triggers an AJAX post (invites_controller.rb) respond_to js opens a hidden div, generated from a partia...

Validate presence of one field or another (XOR)

How do I validate the presence of one field or another but not both and at least one ? ...

AJAX: using an HTML select to add/remove/create new items

I've seen this type of UI element before in a few places, and I'm wondering what it's called and if there is a plugin for it in Rails. It's basically a compact way to let people add/remove/create new of something, commonly tags or labels. I could write it from scratch but would rather not if it's already created. The pull down might h...

Rails Gem Bundler breaking Dependencies

I recently installed the Bundle gem (stable 2.3.x) with a integrated 3.0 release. The documentation for installing 2.3.x is weak, so I'm looking for help here. I've done everything from this article on installing and configuring gem bundler (Installing gem bundler, defining Gemfile, adding preinitializer.rb, requiring bundler_gems/en...

Ruby on Rails - Currency : commas causing an issue.

Looking on SO, I see that the preferred way to currency using RoR is using decimal(8,2) and to output them using number_to_currency(); I can get my numbers out of the DB, but I'm having issues on getting them in. Inside my update action I have the following line: if @non_labor_expense.update_attributes(params[:non_labor_expense]) pu...