ruby-on-rails

About presenter pattern in rails. is a better way to do it?

I have in my model: def presenter @presenter ||= ProfilePresenter.new(self) @presenter end The ProfilePresenter is a class that has methods like, get_link(), get_img_url(size), get_sex(), get_relationship_status() and other methods that have not to do with the model, not even with the controller but is used multiple times in the...

Looking for a web pdf viewer, not the google document viewer

I would love to use google document viewer, but I am dealing with sensitive documents and google's Terms state that if you use their service the document basically becomes public domain. Are they any alternatives that will keep your content private? Also it would be best if there was the ability to disable printing and downloading. FY...

Showing a diff between two bodies of text in Rails

Is there an easy way to do this - create marked up text that shows the changes between two pieces of text. A built-in helper maybe? Looked but couldn't find! ...

Paperclip Progres bar

I havve been looking around for something that shows the progress of an upload using Paperclip. I can't find any solutions is there any out there? If not is there any particular progress uploader that can be recommended? ...

What Test Environment Setup do Committers Use in the Ruby Community?

Today I am going to get as far as I can setting up my testing environment and workflow. I'm looking for practical advice on how to setup the test environment from you guys who are very passionate and versed in Ruby Testing. By the end of the day (6am PST?) I would like to be able to: Type one 1-command to run test suites for ANY proj...

Rails: how to require at least one field not to be blank

Hi I know I can require a field by adding validates_presence_of :field to the model. However, how do I require at least one field to be mandatory, while not requiring any particular field? thanks in advance -- Deb ...

What's the difference between URI.escape and CGI::escape

And which one should I use? ...

Create doc for rails, plugins, app in a single file

I was wondering what the best option for generating doc for rails, its plugin and the app in one single file that I can navigate. I've been using rdoc but that creates multiple files, yard is too slow and hanna gets stuck at random places. Any help? ...

How to customize flash message based on success or failure with Inherited Resources Rails plugin?

I'm using the inherited resources plugin in a 2.3.5 Rails application and was wondering how to change the flash[:notice] (or any other flash) based on the success OR failure in my create and update actions. So given the below, how do I add flash[:notice] = "All good" if success ... and flash[:notice] = "All bad" if failure? Thanks cla...

Rails is caching when I don't want it to. Why?

Rails is caching the index method of one of my controllers. It's a very simple application and only has like 2 controllers and a handful of actions each. The weird thing is I don't have any caching in my application at all, at least not explicitly. The pages get uncached if I restart passenger. Does rails do some kind of automatic page c...

Archiving an Entire Rails Site

I have a Ruby on Rails site that was only needed for a short period of time during which users added various objects to a mySQL database, commenting on them, associating themselves with them, etc. etc. etc. The question is this: the site is no longer needed until a week next year around this time when I will clear the database and use ...

how do i write action methods for partial views?

I rendering a view partially like this. <%= render(:partial => "index" ,:controller=>"controller_name") %> so this will partially render controller_name/_index.html.erb here is my doubt. can i write an action method for this _index. something like this? class ControllerNameController < ApplicationController def _index end end ...

How to completely wipe rubygems along with rails etc

Ok, so I decided I'd be cool and try to use Rails3 that's in beta. Then, things were getting hard to manage so I got rvm. I installed ruby 1.9.2-head in rvm and things were working, and then a computer restart later rails wouldn't start up. So I figured I'd just try running the system ruby and start rails in it. same error. Then, I unins...

Rails routing of a controller's functions query

So I've got a Users controller, and it has (amongst others) a function called details. The idea is that a user can go to localhost:3000/user/:user_id/details and be able to view the details of :user_id. For example, I have a user called "tester". When I go to the uri: http://localhost:3000/users/tester/details I'd want the details func...

Get methods params type parsing wsdl file in a rails/ruby application

Hi, I have a question about ruby and wsdl soap. I couldn't find a way to get each method's params and their type. For example, if I found out that a soap has a methods called "get_user_information" (using wsdlDriver) is there a way to know if this method requires some params and what type of params does it require (int, string, complex...

Import 5 millions records to the rails application

We need to import large amount of data(about 5 millions records) to the postgresql db under rails application. Data will be provided in xml format with images inside it encoded with Base64. Estimated size of the xml file is 40GB. What xml parser can handle such amount of data in ruby? Thanks. ...

Can i use a model object directly in a find

I have the following models: student class teacher a student can have multiple classes, a class can have 0 or 1 teachers. I want to be able to call a method on the student to see if they have a specific teacher, and return true or false. The following code seems to work, but i thought it looked a bit long winded, having to compare eac...

what is the best to use - ruby gems or ruby plugins

Hi All, What is the best practice when creating a rails project 1 - is it good to use ruby gems 2 - or is it good to use ruby plugins (as almost all the gems has their plugin versions) and what are the strengths and weaknesses of eachoption consider we are creating the rails project with rails 2.x.x or rails 3 thanks in advance ...

Slow queries in Rails- not sure if my indexes are being used.

I'm doing a quite complicated find with lots of includes, which rails is splitting into a sequence of discrete queries rather than do a single big join. The queries are really slow - my dataset isn't massive, with none of the tables having more than a few thousand records. I have indexed all of the fields which are examined in the que...

Markdown to text/plain and text/html for multipart email

I’m looking for a solution to send DRY multipart emails in Rails. With DRY I mean that the content for the mail is only defined once. I’ve thought about some possible solutions but haven’t found any existing implementations. The solutions I’ve thought about are: load the text from I18n and apply Markdown for the html mail and apply M...