ruby-on-rails

How to make rails autospec stop looping

I'm using autospec and when all tests are passing, the green messages pops up just once, but when the tests are NOT passing, it remains popping up infinite red windows in growl. Does anybody knows how to turn this off and make autospec run just after I save my files? I have a .autotest file in my home with these contents: require 'aut...

What's the equivalent of Rails' Migrations or Django's South in Pylons and TG2?

Does anyone know how Pylons and TG2 projects handle database migrations? I'm looking for something similar to Rails' Migrations and Django's South. ...

will_paginate undefined method `total_pages'

What am I missing here? I am using the haml_scaffold generator and the pages work fine with will_paginate. When I start tinkering I end up with this 'total_pages' error and I'm not sure what I am doing that is causing it. Anyone have any insight? I'm using mislav-will_paginate 2.3.11. mike@jauntyjackalope:~/project$ script/console Load...

Use helper methods within a controller

I defined a helper abc() in annotations_helper.rb. What do I have to do such that I can use this method in annotations_controller.rb? ...

Map.connect with a hyphen in the URL

I want http://localhost:3000/note-1828 to map to a controller action. I've tried this: map.connect "note-:id", :controller => "annotations", :action => "show", :requirements => { :id => /\d+/ } But it doesn't seem to work (No route matches "/note-1828" with {:method=>:get}). What should I do instead? ...

What are the main concerns when generating client-side JavaScript from the server?

This seems like a somewhat common issue and I'm wondering what the common pitfalls, best practices, best approach, security concerns, etc., are when creating javascript on the server to be later loaded client side. FWIW, I'm doing this in Ruby and I'm using JQuery as well. It's basically a form builder. Here's what I'm doing: I have an...

Exception Notifier stop working after upgrade rails 2.3.4

The exception notifier working fine till yesterday my production server upgrade to rails 2.3.4. please help. Error are wrong number of arguments (3 for 2) [RAILS_ROOT]/lib/smtp_tls.rb:8:in `check_auth_args' Backtrace: [RAILS_ROOT]/lib/smtp_tls.rb:8:in `check_auth_args' [RAILS_ROOT]/lib/smtp_tls.rb:8:in `do_start' /System/Library...

Can't run Rake commands any more, hpricot_scan.bundle no suitable image found

Hey, Since I migrated to Snow Leopard I can't run any Rake command from the command line. e.g if I try to run rake stats I get: rake aborted! dlopen(/Users/xxx/.gem/ruby/1.8/gems/hpricot-0.8.1/lib/hpricot_scan.bundle, 9): no suitable image found. Did find: /Users/xxx/.gem/ruby/1.8/gems/hpricot-0.8.1/lib/hpricot_scan.bundle: no ma...

How to recover cancelled (taken) jobs in case of BackgroundRB crash?

The problem: we have jobs that run from a few seconds to a few minutes in BackgroundRB from a Rails app. But, what happens when we deploy new code and restart BackgroundRB when it's performing a task? BackgroundRB does not seem to pick up any 'taken' tasks and I have not been able to find anything that can recover these tasks. Can anyo...

Updating an element with RJS

I have an 'Save' button on my application, which saves a record via AJAX once edited. That code is working lovely. I have discovered a little bug though. If I click the save button, eventually the code below is invoked: page.replace_html "status-#{@restriction.id}", "Saved." page.delay(2) do page.visual_effect :fade, "status-#{@restri...

Notification in rails

Everytime a registerd user updates their profile, I would like the administrator to get an email notification about this. In Drupal notification module will do this need How can this be done in rails? ...

Ruby Web API scraping / error handling with Hpricot

I have written a simple ruby gem to scrape a set of websites, providing a simple API, inside the gem itself I have included a retry method... to attempt to use Hpricot 3 or more times on failure mostly due to timeouts. def retryable(options = {}, &block) opts = { :tries => 1, :on => Exception }.merge(options) retry_exception, retri...

str_to_date for ruby on rails?

so I have to insert a bunch of records from a data source that has dates in the format Sun, Sep 13 1:00 PM. I'm just going to execute SQL that uses STR_TO_DATE But I was wondering in case I need it in the future if you guys know of a way to do this using a ruby method...like a reverse strftime ...

Adding thoughtbot's open_id_authentication to thoughtbot's clearance

I am working on an application that is currently using thoughtbot's clearance as its authentication piece. I want to add openID to this application and know that thoughtbot has an open_id_authentication plugin. Does anyone know how easy it is to go about doing this or if there is a tutorial or anything somewhere? ...

Why do my controller's instance variables not work in views (Rails)

I would like to add a couple of instance variables to my controller, since the variables in question are required from within more than one action's view. However, the below example does not work as I would expect. class ExampleController < ApplicationController @var1 = "Cheese" @var2 = "Tomato" def show_pizza_topping # What ...

Three Column Join in Rails with Active Scaffold

I have a join table with three columns. I've tried defining the three models with both a has many through and habtm. I am using active scaffold just for CRUD functionality then it will get phased out. I have a feeling that if I want a three column join table, I'm going to have to phase out active scaffold early and write a custom help...

Rails CookieOverflow

Suddenly, in my first Rails app, I've started seeing this error: /!\ FAILSAFE /!\ Fri Sep 11 17:30:48 -0400 2009 Status: 500 Internal Server Error ActionController::Session::CookieStore::CookieOverflow A little research points to the usage of of cookies to store session data, but I'm not doing that (at least not intentionally). Moreo...

Ruby on Rails: how to use sessions to implement remote sign-out?

Hi everyone, My goal is to allow users of a Rails web app to see all their open sessions on other computers and close/sign out of them remotely. Similar to gmail's "Account activity" page (link found at the bottom of the gmail inbox page). I can technically achieve this by using the sessions in the database account_sessions = CGI::Se...

Ruby on Rails Actions help

I have my index page which posts a single entry instead of the usual scaffold default of all of the entries. I told it to link to an action and it just responds to "Couldn't find Post with ID=all". It is the same as the default index method and index view. I assume this has something to do with routing but being no I have no clue. Any id...

Ruby on Rails - Login

So I do not reinvent the wheel, what is the best way to setup a registration, login, logout and password reset framework for Ruby on Rails? Ideally, there must be a gem (library, package, etc) that handles this?? Thanks in advance! ...