ruby-on-rails

Screen Scraping with Ruby on Rails

Hi everyone, Am a newbie in RoR. I want to develop a rails app, which could search flight info from my rails app, fetch the flight informations from various airlines sites(for example; airasia and malaysia airlines). display those results back in my rails app. My search module should include the following textfields: From: Kuala Lumpu...

Plugins not getting properly installed

Hi, i am having this annoying problem when deploying rails plugins. I can install them by downloading the source and putting it in the vendor/plugins directory, But i want to do it with the easy command line. I am trying to install the will_paginate plugin. tried this command ruby script/plugin install git://github.com/mislav/will_pagin...

searchlogic with globalize2?

Given there is a model: class MenuItem < ActiveRecord::Base translates :title end and searchlogic is plugged in, I'd expect the following to work: >> MenuItem.search(:title_like => 'tea') Sadly, it doesn't: Searchlogic::Search::UnknownConditionError: The title_like is not a valid condition. You may only use conditions that map t...

Using Paperclip to Process .tga (targa) Files

I've run into an annoying problem with Paperclip. Paperclip is working fine for uploading jpg/gif files but it's choking on .targa files with the error "not recognized by identify”. Just to confirm, it's working 100% with jpg/gif/png files and I have imagemagick installed and working, this error only occurs with .tga files. The general ...

Rails: When a model? When a lib?

I'm making a little message sending module. It'll handle queuing messages from a request to be picked up by a background worker to send email/SMS (or log appropriately for testing). Question: is this a Model (under /app/models) or a lib (under /lib). I'd like some religion on this. Theory A: (My current theory) Unless you're subclassi...

One or more params in model find conditions with Ruby on Rails

Say I have model 'Car' and controller 'cars', and a method 'display'. I have multiple attributes like: in_production, year, make I can easily do something like this to find cars that match all the parameters passed: def display @cars = Car.find(:all, :conditions => { :in_production => #{params[:in_production]}, :year => #{param...

How to display images in Rails without plugins like Paper Clip?

I'm trying to display images using my web application written in Rails. I've come across solutions like PaperClip, Attachment Fu etc; but they modify my data model and require to save the image through UI. The problem is that, the images content is not stored using Rails, but a Java Servlet Application. Is there a way to just display the...

state_machine only works for new records

I can't seem to get the state_machine gem (http://github.com/pluginaweek/state_machine/) to work on existing records (it works correctly on new records). Here's my model: class Comment < ActiveRecord::Base state_machine :state, :initial => :pending do event :publish do transition all => :published end end end and he...

Rails - Providing License Key to Plugin Based on Hostname

I'm using New Relic for Rails, but only need New Relic to monitor my one production environment. However, I have a staging server that also runs in Production mode. New Relic detects both as operating prod instances of my application (as it should), but I don't want to have to pay for monitoring two instances when I only want to keep a...

FasterCSV: columns into an array -- rails

I'm trying to get fastercsv setup so that rather than parsing each row, it will place each column into an multi array. CSV import file: id, first name, last name, age 1, joe, smith, 11 2, jane, doe, 14 Save to array named people: people[0][0] would equal id people[2][1] would equal jane This is what I currently have: url = 'http://u...

How to make ActiveRecord work with legacy partitioned/sharded databases/tables?

Hi all, thanks for your time first...after all the searching on google, github and here, and got more confused about the big words(partition/shard/fedorate),I figure that I have to describe the specific problem I met and ask around. My company's databases deals with massive users and orders, so we split databases and tables in various ...

Rails & jQuery - getting UnknownAction error when checking username availability

Hi - I'm trying to write a small jQuery method that works on my rails site and check if a username is available. This is all handled in the users_controller.rb and on the form: <script> $( function() { $('input#username').keyup( function() { var username = $('input#username').val(); url = '/users/check_username/'; ...

Is Instant Rails dead?

The last updated download on RubyForge (http://rubyforge.org/frs/?group%5Fid=904) is dated 2007-12-28. In Rails terms that is sometime in the last millenium. Is this project dead, is there an alternative? ...

Using parameters in my controller

So I'm using the excellent Ancestry gem But while the documentation seems very complete I don't understand how to pass the parameter of my element which I want to be the parent of my newly created element. Firstly, do I want to do it in the new or create action... allow me to explain. For example: (with some actions removed for brevity) ...

Send an XML message to Amazon SQS

I am a newbie to Amazon SQS and ruby on rails. And i am working on a project that some XML messages must be send to SQS. How do i do that? Now i have this in the controller after the .save def create @thing = Thing.new(params[:thing]) respond_to do |format| if @thing.save message = @thing.to_xml and in the...

TDD/BDD in particular for a Rails application

How granular should one get when using TDD/BDD methods for developing an application? In particular with regards to a Rails application. Would you test for every single field individually and then right the migration that will make it pass? So every field would have it's own migration? What would you actually test against to make sur...

How best to cope with naming scheme changes in a Rails app

I look after an Rails app, that's about to have some key user facing parts renamed (like urls, and other such change like renaming 'blogs' to 'journals' and so on) I'm slightly worried that over time, having loads of older names in the codebase for all the methods, routes and classnames is going to be difficult to read and maintain. Wh...

TMail Object Missing BCC Information

I am running a cron job that checks for new email on a Gmail account every minute. If any new mail is found, it triggers a receive function that begins as follows: def receive(email) # REPORT SOME INFORMATION ABOUT INBOUND EMAIL RECEIPT puts "SUBJECT: #{email.subject}" puts "#{email.class}" puts email.to.inspect...

Using Capistrano to deploy a Rails application to multiple web servers

I'm currently setting up a new production environment for a Rails application which includes multiple, load-balanced application servers (currently only two, but this will increase over time). I'd like to handle deployment of the app to all these servers in a single command using Capistrano (which I already use for my existing, single...

Configuring Rails CSS Caching with Passenger

I am using Passenger and Rails' :cache => true to cache all my css into one big file. Deploys are done via Capistrano. Now sometimes(!), the mem-generated all.css file can't be found after the app is restarted (and I get an error in the log) ActionController::RoutingError (No route matches "/stylesheets/all.css" with {:method=>:get}): ...