I've heard of the various background task tools (delayed_job, starling, workling, etc) but from looking at those it seems they're really only capable of running model-based methods (User.update_counters, for example).
I need to be able to run a controller method as it's a pretty complex set of tasks that's intertwined a slew of other co...
We just had an existing use of redirect_to break due to a Rails upgrade, and it led to a question. I've been experimenting, and I don't seem to find a way to use redirect_to to send the user to a non-Rails page with query parameters appended, except by manually constructing the URL string, which seems like a shame. Previously, just a sim...
I have a site: www.mydomain.com where we have administrative controls hidden away from normal customer view. I would like to only access the administrative features under a subdomain such as admin.mydomain.com. I can ensure that any requests to an administrative feature has to have admin in the subdomain, but how can I make sure that i...
I have a small third party flash application I'd like to incorporate in my rails app, but I am struggling to get it working properly.
I believe it belongs in vendor opposed to lib, correct?
Let's say I want the flash app to be loaded in my users controller in the signature action, how would I go about loading it in there. The app has m...
Hi, I am doing something seemingly pretty easy, but Rails is messing up the SQL. I could just execute my own SQL, but the framework should be able to handle this.
Here is the save I am trying to perform:
w = WhipSenVote.find(:first, :conditions => ["whip_bill_id = ? AND whip_sen_id = ?", bill_id, k])
w.votes_no = w.votes_no - 1
w.save
...
Hi all!
I have a Model called Section which has many articles (Article). These articles are versioned (a column named version stores their version no.) and I want the freshest to be retrieved.
The SQL query which would retrieve all articles from section_id 2 is:
SELECT * FROM `articles`
WHERE `section_id`=2
AND `version` IN
(
SELEC...
I need to save a copy of an ActiveRecord object so I'm using something like:
@original = Model.find(params[:id])
@copy = @original.clone
However, when I attempt to save this to Postgres:
PGError: ERROR: null value in column "id" violates not-null constraint
In the console:
@copy.id
=> nil
How do ...
Is there any way to configure Capistrano for deploying many webs on a server?
I would like to have a project on port 80 an other project on port 1000 and manage each one with different dbs.
...
I am wondering what is the best way to convert a json formated key value pair to ruby hash with symbol as key :
examole:
{ 'user': { 'name': 'foo', 'age': 40, 'location': { 'city' : 'bar', 'state': 'ca' } } }
==>
{ :user=>{ :name => 'foo', :age =>'40', :location=>{ :city => 'bar', :state=>'ca' } } }
Is there a helper method can do t...
I am a Rails beginner and trying to understand how rails migration works.
I have created a scaffold like:
script/generate scaffold Item col1:string col2:text
rake db:migrate
I would like to add another col4 using migration:
I created a migration as follows:
class AddCol4 < ActiveRecord::Migration
def self.up
add_column ...
Given I am a dumb programmer
and I am using rspec
and I am using spork
and I want to debug ...mmm...let's saaay, a spec for Phone.
Then, where should I put the "require 'ruby-debug'" line in order to halt processing at a particular point in the phone_spec.rb? (All I'm asking for is a big fat arrow that even a challenged programme...
The GitHub guys recently released their background processing app which uses Redis:
http://github.com/defunkt/resque
http://github.com/blog/542-introducing-resque
I have it working locally, but I'm struggling to get it working in production. Has anyone got a:
Capistrano recipe to deploy workers (control number of workers, restarting ...
I can't seem to wrap my head around this, so I thought I'd post and see if anyone could help me out (please pardon the question if it's insultingly simple: it's complicated to me right now!)
I have these models:
order
service
customer
I think they speak for themselves: a service is what the customer buys when they place an order.
O...
What I want to do seems simple, but might not be "proper"
let's say I have an image resource, and I manipulate the image based on the url. In the url I want to specify it's size and whether it's grayed, colored, or dimmed or some other condition.
currently I have a number of named routes that look like this.
map.gray_product_image "im...
I'm developing a front-end to a Rails application. In cross-browser testing, I immediately discovered that Internet Explorer (apparently all modern versions, but at least IE 7 and IE 8) is not correctly interpreting a file I'm trying to load via AJAX (with jQuery) as JavaScript. A file download warning appears and the user needs to confi...
I'm considering developing aspects of a website as Rails plugins for reuse. My question is about the development process. Since each of these plugins will provide a "slice" of functionality, should I develop each "slice" as it's own application and then extract the code from each application into a plugin? Or, should I write them as p...
My Environments:
CentOS 5
ruby 1.8.6 (2008-08-11 patchlevel 287) [x86_64-linux]
Ruby Enterprise Edition 20090610
passneger or webrick
I use this gem list.
*** LOCAL GEMS ***
actionmailer (2.3.2, 2.2.2)
actionpack (2.3.2, 2.2.2)
activerecord (2.3.2, 2.2.2)
activeresource (2.3.2, 2.2.2)
activesupport (2.3.2, 2.2.2)
fastthread (1.0.7)
h...
I have a form with a nested object (customer < order), and it works except that it keeps creating a new customer record.
I'd like to have it check to see if an existing customer is already present in the database (using the customer's email address to search), and if so, just attach the order to the existing record, but if not, contin...
I have this validation in my user model.
validates_uniqueness_of :email, :case_sensitive => false,
:message => "Some funky message that ive cleverly written"
In my tests I want to ensure that when a user enters a dupe email address that my message definately gets shown but without having to duplicate the error string from abov...
In other o/s RSpec returns nicely coloured results (red, green etc).
However in the windows (Vista) command prompt my text output is just plain old boring white.
How can I bring colour to my RSpec test results?
Thanks
Evolve
...