ruby-on-rails

Is it possible to do validation on a form item that isn't part of the model?

So I've got a signup form and part of it is billing/credit card info. That info is all stored and processed by a third party app and so the data isn't stored in our database. So how can I still run the items through the validates_ methods in Rails? (validates_presence_of, validates_length_of, etc etc) Or am I going about validation in ...

Multiple Nested Routes, is there a better way to do this?

So In my rails app I have two resources (rentals, and reservations) which belong to a user. This is the code in my routes.rb to set up the nested routes. map.resources :users, :has_many => :reservations, :shallow => true map.resources :users, :has_many => :rentals, :shallow => true map.resources :rentals, :only => [:index] map....

Prevent image caching in rails on a per tag basis

We are using gravtars for a site currently being developed in rails 2.3.4 and i am finding that the rails side tends to cache the images even after there is a change at the gravtar side. I know with javascript you can prevent caching when using thejavacript_include_tag :cache => false method, however, is there a way to prevent the cache...

FreeTDS Bad token from the server (sql-server)

Today we had a lot more activity than normal between our Rails app and our remote legacy MS-SQL Server 2005 database, and we started getting the error below intermittently. Any ideas what it is + how to prevent (besides avoiding the situation, which we're working on :) Error Message: ActiveRecord::StatementInvalid: DBI::DatabaseError: ...

SSL slowness in EC2

We've deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web servers. Each web server also runs nginx with a cluster of mongrels. The nginx here takes care of static content and load balancing the mo...

Trying to understand what Base.rakismet_binding is for

What does this part . . . unless Rakismet::Base.rakismet_binding.nil? { :referrer => 'request.referer', :user_ip => 'request.remote_ip', :user_agent => 'request.user_agent' }.each_pair do |k,v| data[k] = eval(v, Rakismet::Base.rakismet_binding) || '' end end of the following method do? module In...

Starting out with rails. Suggestions for SDKs plug-ins etc?

I have 6 years of C# programming experience and I'm looking to broaden my horizons. I'm going to build a simple web app to demonstrate knowledge of Ruby on Rails so I can get my foot in a place that might want a Rails programmer. It's the hot new thing, so I want to be marketable. Anyway, I have been playing around with solr and tomcat ...

Implementing globalization in Rails

While I have experience developing Rails apps in English, I am a blank slate when it comes to handling globalization, so please don't shoot me in the head if my question 'doesn't make sense' :) I have been asked to add multi language feature to a part of a Rails app that I am working on. Initially its only going to be 2 languages, Fren...

Git on InstantRails

I am a beginner in using Rails and Git I have InstantRails installed and created an app by: $ rails myapp It created all the necessary files. I went to the directory, $ cd myapp then I tried initializing git $ git init but it said : 'git' is not recognized as an internal or external command, operable program or batch file. So I fi...

rspec testing views with internationalization ?

Hello, I want to make sure I have the right meta desc/keyword and title text in my view so I want to create rspec views tests for that. Now the real challange here is how to make it work across multiple languages. The way I've done it is: it "should have the right page title" do title = "some nice title here" response.should have_...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can't see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a scenario where collection_select is better than select? or is anything I am missing here? ...

Recommendations (and Differences) between different Ruby on Rails Production Web Servers

Very soon I plan on deploying my first Ruby on Rails application to a production environment and I've even picked a webhost with all the managed server and Capistrano goodness you'd expect from a RoR provider. The provider allows for Mongrel, Thin, Passenger & FastCGI web servers, which seems very flexible, but I honestly don't know the...

What's the difference between Ruby and JRuby?

Can anyone please provide me in layman's terms the difference between developing a JRuby and a Ruby, Rails application? I use NetBeans as my Ruby on Rails IDE and every-time I create a project is asks me that question - and I don't really get the difference. Are there any pro and cons? ...

How best to expose Rails methods via an API?

Let's say I have a model foo, and my model has a publish! method that changes a few properties on that model and potentially a few others too. Now, the Rails way suggests that I expose my model over rest and let the end user monkey with parameters. What should I do if I want to expose my publish! method instead to protect my model? Is...

Encode a String in Ruby on Rails

How can I encode a string (iso to utf-8 for example) in Ruby on Rails, using Ruby 1.8.7 ? ...

How to use Scriptaculous effects on error messages

I want to use some Scriptaculous effects on error messages. <% form_for(@page) do |f| %> <%= f.label :name %> <%= f.text_field :name %> <%= f.error_message_on "name" %> <%= f.label :content %> <%= f.text_field :content %> <%= f.error_message_on "content" %> <%= f.submit 'Create' %> <% end %> My first ide...

Rails: Receive POST from External Form

I have a form on another website (using a different backend) that I want to be able to POST to my Rails application (on a different domain). How do I generate a valid authenticity token for the external form so that my Rails app will accept it? Assuming I can do the answer to the above question--is there anything else special I need to...

Problem with stylesheet_link_tag

I have add stylesheet link tag to my application. I'm sure its worked. because in another place is working. but if I run at my computer it did not working. I mean my application cant load css when I seen at view source the result is : <script src="http://localhost:3000//javascripts/application.js?1258048544" type="text/javascript"></sc...

Individual Form Params when POST data is split

I'm trying to access a date variable from a form individually to the other variables. The form is a formtastic plugin form. The issue I am facing is that the date is a three-part dropdown and simply doing params[:friend][:born_on] doesn't seem to be doing the trick as it returns NULL. Here is my parameters output; Parameters: {"comm...

How can i see my apache rails server from other computers on my local network?

I have an apache server running, with mongrels underneath running rails. The apache config file for my rails app looks like this: <VirtualHost *:80> ServerName trunk.production.charanga ServerAlias max.trunk.production.charanga DocumentRoot /home/max/work/e_learning_resource/trunk/public RewriteEngine On <Proxy balancer://...