ruby-on-rails

rails different currency formats

Hello everybody. I need to show user amount presented in different currencies. e.q. : Your balance: $ 100 000.00 € 70 000.00 3 000 000,00 руб. So I need to use number_to_currency three times with different locales(en, eu, ru). What is the right way to do it? ...

Rails: Logging for code in the lib directory?

What is the best/easiest way to configure logging for code kept in the lib directory? ...

Why should I deploy as another site (deploy) user?

What are the benefits of deploying your site as a special 'deploy' user? And should I run my main domain and subdomains as a single user? ...

amazon simpledb with aws-sdb-proxy suitable for high traffic production app?

i am using amazon simpledb with the aws_sdb gem and aws-sdb proxy as outlined in a documentation from amazon with ruby on rails and a local aws proxy that runs on webrick (providing a bridge with ActiveResource). see http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1242 i am wondering if the aws-sdb-proxy (webrick!)...

Ruby - encrypted_strings

A bit of a Ruby newbie here - should be an easy question: I want to use the encrypted_strings gem to create a password encrypted string: (from http://rdoc.info/projects/pluginaweek/encrypted_strings) Question is: Everything works fine, but how come I don't need the password to decrypt the string? Say I want to store the string somewhe...

Pre-packaged Rails applications

Seems like most Rails applications have similar 'base' functionality. As such, it seems that there would be value in having pre-build Rails applications at various functionality points such as: basic User model with authentication using Authlogic #1 + openid integration #2 + authorization using declarative_authorization #3 + Administr...

mongodb read/write performance and mongo hosting in the cloud

we are currently developing a high traffic rails application with facebooker (facebook game). since amazon simpledb (aws-sdb) is really slow, we are thinking of using a dedicated mongodb server as offered by mongoHQ for example. questions: what is the read/writes peak value for a mongodb server running on a amazon ec2 instance? what w...

Rails and Python hosting problem

I am trying to host some files/rails app in the port 8080 for external access. For python I am using the SimpleHTTPServer module, and for rails, webrick. However, both of them does not work very well. I don't get the response back, and, sometimes, if I get it, it's VERY slow. Nevertheless, apache works very well on the port 8080 (i am no...

Rails validation issue with before_validation

I'm still fairly new to rails so I'm not sure what I'm missing here. I'm using GeoKit to geocode an address upon saving. I have a method that geocodes an address and if it fails to find it, it adds an error to the errors list. I've tested it in the console and it is failing on the geocode (presumably adding the error) but still saving s...

How to make will_paginate work with liquid

I managed to make a little hack to make will_paginate work with liquid: http://gist.github.com/426737 I wonder if this is safe? Ideas? ...

Rails -- Can't set value for date_select in form

I'm pulling data from an API where the date data comes in as "2008-02-11 00:00:00 " I would like that data to go into my form within the date_select as a value so I can view it correctly before I add it into my database. The view looks like <%= f.label :start_date %><br /> <%= f.date_select :start_date, :value => " #{@stdate[idx]} " %...

Custom Routes and Declarative Authorization

Don't know if this has been answered before. Have custom routes to users. If I access the user directly /users/5 everything works. If I try /profile or even /users/current_user with Declarative Authorization I get "Couldn't find User without an ID" map.profile "profile", :controller => "users", :action => "show" map.edit_profile 'pro...

Is it possible to enforce a controller method to work only for specific HTTP methods?

I was wondering if there was a way to make controller methods in rails available only for specific HTTP methods (GET, POST, etc.). I guess I can create a filter to do that but it seems to me that it is something that is available out-of-the-box in rails. Is it? ...

Which type of Rails model association should I use in this situation?

I have two models/tables in my Rails application: discussions and comments. Each discussion has_many comments, and each comment belongs_to a discussion. My discussions table also includes a first_comment_id column and last_comment_id column for convenience and speed. I want to be able to call discussion.last_comment for the last comment ...

Securing an AJAX API to prevent other sites from taking advantage of it

We're currently developing a site that uses a simple JSON API (RoR) to populate the page. The data is public to clients but key to our service and we want to make sure that our competitors aren't leeching our data. What methods do you use to verify that AJAX requests to an API are legitimate? ...

How to always return a set number of records when using find_related_tags with acts-as-taggable-on

I'm using the acts-as-taggable-on gem and I need to use find_related_tags on my survey model to get back 3 surveys every time. In the event there aren't always 3 related I need to pick how ever many are related plus some random ones to get to 3. Additionally I have a method I wrote called completed_survey_ids which return an array of s...

FBML + jquery Validation + Rails

Hi all, In my local machine i have a scaffold that uses Jquery Validation plugin for the field's validation. Now i want to add that to a fbml facebook application, but i'm haven't been able to load the jquery javascript and the jquery Validation plugin into the app, does anybody now how to do that? or maybe someone could suggest me a ...

rails ajax redirect

Here is my use case I have a search model with two actions search_set and search_show. 1 - A user loads the home page which contains a search_form, rendered via a partial (search_form). 2 - User does a search, and the request goes to search_set, the search is saved and a redirect happens to search_show page which again renders the sea...

image_to_function in Rails

I have this method on rails so that I have an image calling a javascript function def image_to_function(name, function, html_options = {}) html_options.symbolize_keys! tag(:input, html_options.merge({ :type => "image", :src => image_path(name), :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + ...

How do I stub a view in rspec-2

I'm in the process of upgrading an app to Rails 3/Rspec 2. I see that stubbing a view helper method has changed in Rspec 2. It looks like instead of doing template.stub!, we're now supposed to do view.stub!, but I can't seem to get this to work on beta 10. I get an "undefined local variable or method `view' for # < RSpec::Core::Exampl...