ruby-on-rails

Ruby on Rails (JRuby) errors custom error pages (500) not being properly captured

Hello All: Wondering if anyone has come across this issue before, I am using JRuby v 1.5.x and Rails 2.5.x on a Tomcat Server and I am having difficulty capturing an error and redirecting to a 500.html page. Here is a stacktrace. I attempt to capture the error state but to no avail, it goes immediately to rendering the web page. (Att...

Convert DateTime String to UTC in rails

I have a string like this: "2010-01-01 12:30:00" I need that to convert to UTC from the current local time zone. I tried this, but it seems to think that the string is already UTC. "2010-01-01 12:30:00".to_datetime.in_time_zone("Central Time (US & Canada)") => Fri, 01 Jan 2010 06:30:00 CST -06:00 I am not sure where to go from her...

Is Authlogic viable on Rails 3?

I am looking for a good authentication solution. Is Authlogic the way to go for Rails 3? I am having problems and finding a lot of info that others are as well with Rails 3. Should I look at something else? ...

learning RoR, can someone explain this boot.rb from H**ll?

I am looking at this boot.rb file: http://github.com/bestbuyremix/BBYIDX/blob/master/config/boot.rb And after trying to understand it, it is as if I have learned nothing so far. Can someone detail what is going on here? I have no idea how someone could even come up with this? # Don't change this file! # Configure your app in config/...

Is this a better way to index with Thinking Sphinx?

There has been a post about setting cron job to index: Use a Cron Job to Automate Sphinx Index Refresh from Rails Rake Task The author shares the same technique to invoke the indexer through Thinking Sphinx. But in the comment, there is a second method shared, which claimed to be better in easing the server load by calling the indexer d...

Database and model setup in Ruby On Rails

Hi I'm pretty new to database setup in Ruby and need help in setting it up correctly along with the models. Can anyone help? Basically I have an Organisation, which will have at least 2 types of Users - Member and Admin User. Both the Organisations and the Users have an Address. I was thinking this was basically three tables - Organ...

Paperclip thumbnail regeneration timeout?

I'm trying to run the Paperclip thumbnail regeneration task using paperclip:refresh:thumbnails CLASS=Photo but after sitting for ~5 minutes, I get a "rake aborted! Broken pipe" error. The images are stored on S3. Here is the full trace on the task: Shpigford:pugspot_v3 Shpigford$ rake paperclip:refresh:thumbnails CLASS=Photo --trace (...

Rails CMS for inserting multi-language text?

I'm looking for a Ruby on Rails CMS and I want it to support multi-language text input. I mean, for example, I would like to insert a text into a section, in three different languages. But, I don't need a multi-language admin panel though. Could anyone recommend me any? Thanks, Brian ...

How to redirect without www using Rails 3 / Rack?

I understand there are a lot of questions that answer this. I'm familiar with .htaccess and nginx.conf methods, but I do not have access to such traditional configuration methods on heroku. Simone Carletti gave this answer that leverages Rails 2.x Metals, but I'm using Rails 3 and this isn't compatible. http://stackoverflow.com/questio...

Staying DRY while testing a controller, authorized via CanCan

I'm retroactively writing some tests, using RSpec, for a Rails project. I'm using the CanCan gem to provide authorization. I decided to write a spec that will test the ability.rb model. I then went on to test my remaining models. I've moved on to controllers, and I've run into a huge snag: I'm testing my abilities all over again! Basi...

What to do after Rails deployment. Please help!

Hello! I am am a newbie in Ruby on Rails development and I am learning this fantastic framework fast and easy. The only problem (which is a big one) is how to deploy. I have tried a Linode StackScript which installs Ruby, Rails, Passenger and Nginx and I have made a "cap deploy" and all files was sent to the server but how on earth do ...

How to have searchlogic initialize with no records

...

Factory Girl error with has_many relationship

Hi, I have the following factories: Factory.define :email do |email| email.email {"infomcburney.cowan.com"} end Factory.define :lead do |lead| lead.emails {|emails| [emails.association(:email)]} end Which are modeling the following classes class Lead < ActiveRecord::Base has_many :emails end class Email < ActiveRecord::Base...

Rails 3 - select with Include?

I've been looking for how to do a select with include in Rails 3 - I have a nested example: @items = Item.where("fulfilled = ?", true).includes({:order=>[:supplier, :agent]}, :manufacturer) This is a very taxing query to run without selects as it creates 1000s of rows of data by pulling information from all the above big tables. How ca...

Rails Json response help

In my controller i have: @photo = Photo.find(:all) respond_to do |format| ... format.json { render :json => @photo.to_json) end so my response looks like: { "photo": { "updated_at":"2010-10-14T19:12:35Z", "photo_file_size":206422, "created_at":"2010-10-14T19:12:01Z" } ...

How to do user content from CMS in Rails

I'm trying to build a CMS in Rails from scratch, and for showing the user generated pages I'm having trouble deciding exactly how to do it. The way I have it right now, I have a controller named 'content' with a single action called 'show'. In routes.rb I have a rule that passes any name after the name of the website to the content con...

How can I populate an activerecord model (and it's associations) from an uploaded file

I have a rails app where I'd like to populate the fields and associations of a model through a file upload. The user is presented with a form with a file upload input element, then after clicking submit, the rails app parses the file and uses it to build a number of other models. A simplified example would look like this (note that for ...

Crop different sized rectangle thumbnails into squares without distorting

Our site takes many different sized thumbnails and converts them to squares for sorting. The squares are 135px x 135px. Our current setup: :styles => { :thumbnail => '135x>' } As you can see, this is downsizing the image to 135px height (while keeping the aspect ratio), the foces the width to 135px causing the image to become t...

Rails 3 - Time Comparison?

Hello, I'm working to do the following in my Rails App: if record.updated_at > 15.minutes.ago do some stuff end Meaning... If the record.updated_at was over 15 minutes ago, do some stuff... This doesn't seem to be working. Ideas? ...

Replace variable value with plain text or ignore it if value is not available.

I have the following code for javascript: function append_place(street, city, state, country) { var address = street + ', ' + city + ', ' + state + ', ' + country; $(".shop_location").append(address); street, city, state, country are external variables drawn from database. (I'm working on Ruby on Rails project by the way.)...