ruby-on-rails

Updated (current) recommendation on Rails versus Django?

(Disclaimer: I asked this question yesterday on HN http://bit.ly/m6onk. While responses were good, there was a notable lack of technical discussion and more of a "you should use rails because that's what you know". Since Joel and Jeff state clearly they don't mind reposts of questions from other sites...and since I really enjoy the answe...

Ruby and Rails - oauth and http proxy

Hey all, Does anybody know how to implement an HTTP PROXY with oauth for rails? I'm using the oauth gem but am behind a proxy server. Finding it very difficult to work this out. Very frustrating! Thanks for any help, John ...

Architectural best practices - where to put non-REST actions?

I'm making my first real Rails app, and am learning about REST architecture and how it fits into Rails apps. My controllers don't really seem to map logically to an individual resource, so it's tough for me to implement strict REST. For instance, I have a "catalog", "checkout" and "admin" controller, not a "products", "categories", "orde...

Which framework offers similar functionalities to ADO.NET Data services

I am new to both Django and Rails. I am thinking of developing an Web 2.0 style application and is planning to expose Restful services, which my UI tier would call to make CRUD operations (Something similar to ADO.NET Data services) I am yet to decide on the platforms and is looking for some advice on which one to side develop on? I am...

rendering open office files in ruby on rails

Hi All, I'm trying to render .odf files from a controller action in a rails application. I'd like to be able to put templates inside my view folders called show.odp.erb, show.odf.erb, etc.. and have that represent the content.xml file that is inside the zip. I'd also like to be able to render these actions in the controller like so: ...

How to best secure records in Rails?

I have some records in my database which only the owning users, or administrators are allowed to view/edit etc. What is the best way to secure these records on an application level so that only these people can see these records? I could do this manually with conditions, but I would need to ensure I use the same conditions on every sin...

Logging in ruby on rails

How can I setup the automatic cleanup on test.log and development.log in ruby on rails? Is there a setting to automatically delete dev and test logs on server start and tests run? ...

(Rails) Various associations between otherwise unrelated entities?

Hi All, Ok, I've got a bit of an odd situation (as if none of my others were...). Basically I have a setup where there are 4 entities: Sites -> Buildings -> Meters -> Values I then have a fifth entity (Charts) that creates reports on the Values. I have a request to allow for Charts to be visually associated with any of those items ...

Batch Looping A Model With Ruby

I know of the find_in_batches method for ActiveRecord, but this doesn't allow me to set my :order or :limit. I am trying to loop through my data, and for every 6 items I want to wrap them in a <div>. I was trying to whole... <% i = 0 @media.each do |media| %> <% if i%6 %><div class="section"><% end %> [...] <% if i%6 %></div><% en...

What exactly is a "role" in Capistrano?

What is the purpose and function of "roles" in a Capistrano recipe? When I look at sample recipes, I often see something like this: role :app, 'somedomain.com' role :web, 'somedomain.com' role :db, 'somedomain.com', :primary => true So it looks like a role is basically a server where Capistrano executes commands. If that's the case, ...

How can I specify separate app and DB servers for Capistrano?

I'm trying to deploy a Rails app to a CentOS server running Passenger. The SVN repository and MySQL database are each hosted on separate machines. (In other words, there's a total of three separate hosts involved.) Here is my deploy.rb file (taken from the Passenger docs): set :application, 'myapp' set :repository, 'svn+ssh://user@svn...

PDFTK Alternative

We've been using a free commandline utility called PDFTK which we make a system call to from a Ruby on Rails app to split PDFs into individual pages. However, it only supports PDF Version 1.4 and back. Can anyone recommend another utility or gem/Rails plugin to similarly manipulate later version PDFs? Thanks ...

Route chaining in Rails?

I'm writing a Conference listing website in Rails, and came across this requirement: chain, in no particular order, a URL to find events, such as: /in/:city/on/:tag/with/:speaker or rearranged like /in/:city/with/:speaker/on/:tag i can handle these fine one by one. is there a way to dynamically handle these requests? ...

Rails routing for namespaced resource deletion

Hi all, I have a page model and a pages_controller within an admin namespace. My routes file looks like this: map.resources :pages, :only => [:index,:show] map.resources :admin, :only => [:index] map.namespace :admin do |admin| admin.resources :pages end I am not able to figure out the correct method to create a link for...

What's the state of the art in email validation for Rails?

What are you using to validate users' email addresses, and why? I had been using validates_email_veracity_of which actually queries the MX servers. But that is full of fail for various reasons, mostly related to network traffic and reliability. I looked around and I couldn't find anything obvious that a lot of people are using to perf...

Order of scopes in ActiveRecord/Rails queries

I'm running a lot of ActiveRecord queries in my Rails app that have quite a few named and dynamic scopes. I was wondering if there is any difference performance-wise in how those scopes are order. For example, could Person.american.adult.find(:all) be an slower than Person.adult.american.find(:all) ? ...

Retrieving and Ordering Multiple Arrays From ActiveRecord Join table - Ruby on Rails

Hi all, first time poster - semi-newb to Rails. Here is my question. Suppose you have the following Polymorphic many-to-many associations in Rails: class Tag < ActiveRecord::Base has_many :taggings, :dependent => :destroy has_many :books, :through => :taggings, :source => :taggable, :source_type => "Book" has_...

[Ruby] Updating a Hash

So I've got this hash here, and I have a loop. When the loop detects that the hash already has a value vendor = "something" -- and the loop's value is "something" -- I want it to just go to the hash and update some values (price, visits). To simplify this, basically I have an array of hashes, and when I find that I already have a hash ...

Webrick Very Slow When Accessing Applications From Remote Desktop

I have a rails application that I'm running on my server. When I go to a remote desktop and attempt to load the application, the server takes a good 3-4 minutes to respond with a simple html page. However, when I load up the page locally on the server, the page shows up in just a second. I tried pinging the server from my remote desktop ...

multiple has_many associations in Rails

Hi, Let's say you have two models which can be associated in different ways: A User has many conversations they have created. (one to many) A User has many conversations in which they are involved. (many to many) My first thought was to store the id of the user who created the conversation in the conversations table, and associate use...