ruby-on-rails

What is the best way to test authlogic-open-id with cucumber and webrat?

I've been having trouble using cucumber and webrat to test authlogic-openid authentication in a rails app. Following Ryan Bates's excellent screencast I was able to install authlogic with the open-id plugin. OpenID works when I login using the browser but so far I've been unable to test the app using cucumber and webrat. I've tried usin...

Recursive model in Rails

I have a trouble trying to get this working. I have an Item model, and each Item can have other items or nothing. So is this possible or do I need to do some magic? ...

Setting up a rails app using vote_fu

Hey Guys, I've recently installed http://github.com/peteonrails/vote%5Ffu/tree/master (vote_fu) on an app I've been working on. Essentially, I just want a list of items (lets say, posts for example) to display in descending order based on votes. I added the acts_as_voteable to the posts model, and the acts_as_voter to the user model....

Where have the countries moved in Rails 2.3.3

Where has the COUNTRIES constant moved to, this used to work: >> ActionView::Helpers::FormOptionsHelper::COUNTRIES NameError: uninitialized constant ActionView::Helpers::FormOptionsHelper::COUNTRIES from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:440:in `load_missing_constant' from...

RubyAMF and Rails 2.3.3

Is anyone else seeing unpredictable results using Flex 3 with Rails 2.3.3 and RubyAMF 1.6.5? I had to revert back to Rails 2.3.2. Anyone have a clue what's going on? ...

Not including field names in validation error messages

If I have the following validation: validates_inclusion_of :dob, :in => Date.new(1900)..Time.now.years_ago(18).to_date, :message => "You must be 18 or older to register" The actual message on the site that shows up is: "Dob You must be 18 or older to register" Is there any way not to include the column name at the beginning of the m...

Rails Memcached Caching

Hello there, I am using memcached in production on a high traffic website and have only just switched to using Rails. I am using Rails 2.3.2. My question is: Is caching of of queries done automatically with this version of Rails? Or do I have to explicitly cache these queries? I have seen conflicting documentation on this issue, and...

Javascript function to turn URLs and email addresses into clickable links

Is there a Javascript library that exposes a function to automatically turn URLs and email addresses into clickable links? Basically I'm looking for something that duplicates the Rails helper auto_link(). ...

How to rescue exception in model?

In Rails. Exception can rescue in controller class but in model class can not. How to rescue exception in model? ...

How do I exclude data from local table schema_migrations from being pushed to Heroku DB?

I was able to push my Ruby on Rails app with MySQL(local dev) to the Heroku server along with migrating my model with the command heroku rake db:migrate. I have also read the documentation on Database Import/Export. Is that doc referring to pushing actual data from my local dev DB to whichever Heroku's DB? Do I need to modify anything...

FCK Editor Spell Check Problem

When clicking on spell check the following error is occuring undefined method `full_sanitizer' for FckeditorController:Class in the popup window Rails Version 2.3.2 FCk Editor Version 0.4.3 ...

How to remove Field Names in validates_presence_of on rails Model

How to remove Field Name in validates_presence_of on rails Model for the following coding validates_presence_of :address, :attributes => true, :discard_if => :invalid?, :on => :save, :message=> "Invalid Address" and the Output is Address Invalid address and I don't want Address field in this validation Please Help me to solve th...

SQL question about counting...

I want to make a query so that I can grab only Locations that have at least 50 Places. I have a table of Locations: Id, City, Country 1, Austin, USA 2, Paris, France And a table of Places connected to Locations by Location_id Id, Name, Details, Location_id 1, The Zoo, blah, 2 2, Big Park, blah, 2 I can join them like so: SELECT p...

Using Send_File to a Remote Source (Ruby on Rails)

In my app, I have a requirement that is stumping me. I have a file stored in S3, and when a user clicks on a link in my app, I log in the DB they've clicked the link, decrease their 'download credit' allowance by one and then I want to prompt the file for download. I don't simply want to redirect the user to the file because it's store...

One controller, different views for normal users and admins

Hello everyone, in my application, I have a "User" model. Each user can have multiple (email) addresses which are defined in the model "Address": Class User < ActiveRecord::Base has_many :addresses def is_authorized(op) # returns true or false end def is_owned_by(user) # returns true or false end end Class Addre...

mobile_fu rendering over AJAX so it seems..

My controller renders regular html, mobile_fu, and javascript as such: respond_to do |format| format.html { render :action => "full", :layout => "application" and return } format.mobile { render :action => "full", :layout => "application" and return } format.js { render :partial => "content", :layout => false and ...

What is the equivalent of Rail's Testing Routes in Django?

I was reading the Rails testing doc and it looks quite comprehensive in explaining the different type of tests. I also noticed the section on Testing Routes. Does anyone know how I can do that in Django/Python? I have a bunch of web sites with some common urls that I need to test. Here's how it's done in Ruby: def test_should_route_...

Rails helper methods for certain REST actions

When I do a rake routes, I see that helper methods are available for certain REST actions for my user model such as new_user, edit_user so I can use methods like new_user_path, edit_user_path etc but they are not available for update or destroy action. To invoke the destroy action, I have to do something like this link_to ‘Destroy’, us...

What is the standard/conventional location for a test text file with rspec?

We've inherited an application that uses a script to import data from a text file, but doesn't test the import script. I'd like to write some tests for that script, and will need test text files (these are not fixture files). Where would you normally put those files? A data directory? In the new support directory? ...

Specifying a param from a route

Consider a PersonController which has a list action. A user can choose to list all people, or only males or females; currently, to do that, they'd have to go to /people/m or /people/f, corresponding to the route map.list_people "people/:type", :conditions => { :method => :get }, :requirements => { :type => /a|m|f/ }, :defaults => ...