ruby-on-rails

formtastic radio buttons and textfields

I have model Stub in y project, and in a formtastic form I would like to make such behaviour. Given I have two radio buttons First radio means I send some default data in 'my_field' in Stub model Second radio is to enable user a text field that he will use to send his own data to 'my_field' in Stub model Any ideas that will not mess to...

reducing cost of Authlogic/find in ajax call

I've noticed that my AJAX calls on my website are slow, and looking at NewRelic RPM I've noticed that most of the cost comes from Authlogic/find. I guess this is because rails needs to look up the user each time (even on AJAX calls), but 147 microseconds seems awfully slow. Category Segment % Time Avg Calls (per Txn) Av...

Mongrel Gzip Compression

I would like to compress my mongrel's output, I found this plugin, but it's from 2007, and I could not make it work. I have haproxy balancing among several mongrels on my server, I've apache, but it's used only for static content, so mod_deflate doesnt affect the page itself. Any suggestion? If haproxy could compress, that would do it...

:dependant => :destroy isn't calling the destroy method before the deletion?

I have a note model, with the following association note.rb has_many :note_categories, :dependent => :destroy has_many :categories, :through => :note_categories The NoteCategory model was created to function as a join table between notes and categories. Initially it was just a model/table, but I've created a controller to do some cus...

How to pull a Sharepoint List with a Rails app?

I would like to enable a rails app to pull from a sharepoint list in order to update a model. Has anybody meshed up these two things? ...

Rails : post-processing a rendered view

Some Rails application generates a view with some information displayed about a resource. I'd like to suppress some of the information through a plugin, without altering nor overriding the view. (A possible way is to rewrite the view in the plugin but this may interfere with other plugins, and I don't want that.) Is there a way to modi...

markaby: using variable as class id

I am using markaby for the first time and would like to use a variable as a class id. Something along the lines of ... mab = Markaby::Builder.new val = 1 id_name = "this_id-#{val}" mab.p.id_name!, "Hello world" This, of course, yields <p id=name>Hello world</p> and what I am hoping for is <p id=this_id-1>Hello world</p> How doe...

Using ActiveRecord models in a gem - how to handle database config

I have several active record models in a rails app and I would like to extract these models into a gem so that I can easily use them in several web apps. The process seems pretty straight forward, except for passing along the configuration for the models. Do I: Add the configuration yaml file to the gem, thus assuring the databases wil...

How to route a form post to PHP file from Rails?

I already have a php file that takes the contents of an html form that I've now converted to Rails. I don't want to rewrite the php in rails but I'm having issues posting to it. I put the php file in the public directory and can access it if I type the address directly but when I submit a form with it as the action rails serves a 404 not...

Can sunspot-solr filter_by nested attributes?

Let's say I have People, and People has_many Watermelon . I have a filter_by that can work for People attributes, for example : :filter_by => 'has_eaten_today' But can I do a :filter_by for the nested attribute of Watermelon? For example : :filter_by => 'watermelons.created_at' Thanks! ...

Can't install mysql gem on Snow Leopard using Zend Server

Hi! There's a lot of information out there regarding installing the ruby/rails mysql gem on Snow Leopard, however, none of it seems to work for me. I'm wondering if it's because I'm using the Zend Server (CE) as my web stack? Here's what I'm running to install the gem: sudo env ARCHFLAGS="-arch x86\_64" gem install mysql -- --with-mysq...

Can't import Rails plugin from GitHub

I want to use the Typus plugin in my rails application, but i can't install it. $ script/plugin install git://github.com/fesplugas/typus.git Initialized empty Git repository in /...../vendor/plugins/typus/.git/ $ script/generate typus Couldn't find 'typus' generator $ ls -al vendor/plugins/ total 0 drwxr-xr-x 2 *** staff 68 Aug 23...

RoR - PayPal ActiveMerchant - Making a Refund

Hi All, I can successfully make a direct payment to paypal using ActiveMerchant in RoR. How can I make refund to a transaction? Thanks, Imran ...

Deprecation warnings on Rails 3 RC don't help me

Very often in Rails 3, when I get a deprecation warning, the line reference I get is in the Rails framework instead of the actual deprecated line! For example, I try to save a user model : irb(main):006:0> user.save DEPRECATION WARNING: save(true) is deprecated, please give save(:validate => true) instead. (called from save at /home/...

Special Character Issue - Rails/DB2

I have a Rails App and users are pasting certain values from MS Word. When I pasted this... Paul’s “Test2” This is what gets rendered in the app... Paul’s “Test†However, and this is the most bizarre aspect of this - this does not happen at once and I have not been able to track the specific circustances that leads to it. So a ...

How do a call a method from the ApplicationController before every method call?

I'm trying to do this update_activity_time everytime a user does something in the app. Ive done this http://blog.tmisoft.com/2009/09/restful-authentication-session-timeout.html the error I get is undefined local variable or method when I did before_filter update_activity_time at the top of my controller. ...

Ruby: group and count the number of results

How can I count the number of results returned by a "group" query without getting the data ? So far, I am just getting a hashtable of results. Is it possible in rails3 to optimize this query ? Vote.group("question_id, user_id").where("question_id = 3").count.count => 2 In this case we are doing a count of this hashtable => {1=>10, 1...

Highrise API Example. help

I am trying to get the highrise api working with my project. total noob. I have an account, have my api key, added to my rails project like so in my controller. require 'highrise' Highrise::Base.site = 'http://MYACCOUNT.highrisehq.com' Highrise::Base.user = 'MYAPI KEY' @person = Highrise::Person.find(:all) in my view i can...

Should I use from_xml or from_json for importing objects?

Hello all, I currently have a PHP app that I'm going to be rewriting in Rails. My idea is to slowly replace all of the PHP functionality with Rails, so both will need to run side-by-side (I think I've got this part figured out). Now, at the moment, each of our client's has a separate database, and as it turns out, it would be really gr...

How to get query time from a Sunspot Search

I've implemented Sunspot to do searching on a Rails App. Is there any way to get the time the query took to execute? Eg. 10 records returned in 0.5 seconds I've been searching around the sunspot docs, but i can't seem to find out if they support this or not. ...