ruby-on-rails

Why does Rails think I have RubyGems 1.0.1 when I have v1.3.5?

I made a change to my shell profile and now when I try to run the Rails console on a Rails app I created, I get this message: Loading development environment (Rails 2.3.4) Rails requires RubyGems >= 1.3.2 (you have 1.0.1). Please `gem update --system` and try again. However, when I run gem -v the output is 1.3.5. What happened here, ...

How to force a record to save itself even if I have not changed any attributes

In order to clean up some bad data I added a before save callback. Now I need to force all the models to be saved again. However no update operation happens if I do this User.first.save How do I force all the models to perform save operation even though I don't have any attributes changed. ...

when to use nil blank empty? (Rails)

Is there any guidelines on how to differentiate between .nil? .blank? and .empty? I'm generally always confused as to when to use them in my application as they all seem to mean the same thing but have different meanings. Does anyone have any cheatsheet on the gory details? ...

Dynamic Table Generation

First let me describe my situation so that you might be able to help me better. There are two parts. 1: I have a program that runs and analyzes a bunch of files. It generates a "report" that will later be fed into a website for DB storage and viewing. This report can contain pretty much any type of data, as the users can query pretty...

Grail or Ruby on rails for an highly interactive event based web application ?

With Java and Perl background, I have narrowed down the web framework choices to Grail or RoR. The web application is a highly interactive content management app ran on private cloud. One vision is to make all the widgets on the web pages to be event driven: click, double click, right click, keyboard shortcuts, etc. Does either fram...

How to display YouTube video icon from Link

Hi, In my Rails app I want users to be able to input video links from YouTube. I want to be able to display the YouTube icon for that link. How can I do that? Thanks, Tam ...

Finding ways to not check a db regularly in rails..

Hi all- I have an application wherein the application will need to check whether one user is waiting for another user whenever a page is loaded. I have entries that look like this: def self.up create_table :calls do |t| t.string "user1_id" t.string "user2_id" t.boolean "active", :default=>false t.strin...

How to provide your app with a network API

I am going to write a Ruby application that implements a video conversion workflow consisting of multiple audio and video encoding/processing steps. The application interface has two core features: queueing new videos monitoring the progress for each video The user can access these features using a website written in Ruby on Rails. ...

Unit tests for 3rd-party libraries

I'm working on my first real-world Rails project. So far, I'm mostly mashing up functionality from 3rd-party libraries. There's a lot of great ones out there, and that's great. I'm wondering about whether writing unit tests around these libraries is necessary/useful or not. For example, I just integrated friendly_id around one of my mod...

problem when trying to setup simple_captcha in Rails

Hi, I have a Ruby(1.9) on Rails(2.3.4) app that I'm currently developing. I want to add Captcha to it and I ran across Simple_Captcha plugin which installs fine but when I try the setup command for it (rake simple_captcha) I give the error below Note: I use rake19 because I have two versions of Ruby (1.9 and 1.8.6 installed) I run ruby...

Modal windows plugin to rails

Hi, I'm starting to digg some rails plugins to create modal forms in rails. Almost all documents that you find are too old (2006,2007) or more focused in php. I would like to create a "feedback" tab that when you click on that, it opens a form. For example, you can check the railscast website, http://railscasts.com/. Ryan Bates made it ...

Rails Functional Test of Arbitrary or Custom URLs

I have a RESTful resource in my Rails app called "Photo". I'm using Paperclip to serve different "styles" of my photos (for thumbnails and the like), and I'm using a custom route to RESTfully access those styles: map.connect "photos/:id/style/*style", :controller => "photos", :action => "show" That's working fine, but I want to write ...

Generating unique tracking numbers

I am building a small rails app and I need a way to generate tracking numbers to give to customers to check up on their status. I want something similar to what the major shipping companies use, but not as long. Im thinking 12-16 characters long is fine, but I dont want something like 0000000001 where people can just type in incremente...

Helper method that encapsulates two form_for blocks

How do you build a helper method that looks like -confirmation_for [@post, @comment] do |f| = f.confirm "Post" %p html here... = f.edit "Edit" and encapsulates two forms like -form_for [@post, @commment] do |f| = f.hidden_field :submission_state, :value => "confirmed" = f.submit "Post" %p html here... -form_for [@post, @...

Ok use for Single Table Inheritence?

I have the need for a user and a contacts model, both have common attributes like first name, last name, sex etc. It thus seemed reasonable to create a model individual and have user and contacts inherit from that model. class Individual < ActiveRecord::Base end class User < Individual end class Contact < Individual end My question...

Condition on a sub table in rails

Hello I have no good title for this question, but my problem is to set a conditon for my sub-table in rails I have a model named "users" and another named "hours", hours is set to "belongs_to :users" and the users-model has "has_many :hours" But my problem is when I try to fetch the users, but just the hours added this month. I want thi...

Areas feature in rails

Asp.net mvc 2.0 is introducing Areas feature. I am wondering what is the equivalent of asp.net mvc areas in ruby on rails framework? How rails handles the modules/sub sites functionality? ...

Action view error

i have some code .. <% @articles.each do |article|%> <%= link_to h(article.title), show_article_path({:id => article.permalink})%></font> <% end %> i have 3 action use this code, but i want to get result only between start_publish and finish_publish or finish publish blank and (only in one action for example Action Posting), then i...

Implementing Remote Login in Rails

Im trying to allow users to login to a website by verifying if they are registered users of a sister website. Im not really sure what is the best way to implement this. The website which is referred to uses authlogic authentication, so would it be wise to have a REST method that the new website calls to obtain a session token of some sor...

MIgrating data from EC2 to S3?

I am running a Rails app using Paperclip to take care of file attachments and image resizing, etc. The app is currently hosted on EngineYard cloud, and all attachments are stored in their EBS. Thinking about using S3 to handle all Paperclip attachments. Does anyone know of a good and safe way for this migration? many thanks! ...