ruby-on-rails

Previewing RestructuredText with firefox while editing in vim

Hi, I want to use vim to edit restructured tex and see the result in the firefox. I found this posting http://www.zopyx.com/blog/editing-restructuredtext-with-vim which shows the way. It works but every time it opens a new instance of firefox. I want it to open only one instance of it not several tabs of it. Here is the code: :com RP ...

Rails custom validations with multi-model forms

I'm having problems with my rails custom validations. def validates_hsp_program(*attr_names) options = attr_names.extract_options! regex = '^(' err = '' $CetConfig.program.each do |key, val| regex << val.to_s << '|' err << $CetConfig.program_prefix + " " + val.to_s + ", " end regex.chomp!('|') ...

How do I allow rails to have javascript: in the data

I have a database of ad html, and some of them contain Javascript functions. Is there a way to have rails allow javascript: tags for a particular attribute on a particular model? To clarify further, I can bring the html up in an edit form, but when I try to submit, my browser (Firefox) says the connection is reset. IE gives me an error...

Inserting Controller Actions between Actions in Rails - Best Practices

What are best-practices (or usual-practices) when it comes to adding more steps in a process in Rails? For example, I am working with the Spree e-commerce Rails platform and I would like to add a multi-step form people should fill out when trying to "Add to Cart" a Product. The current spree implementation of adding a product to the ca...

Rack rSpec Controller Tests with Rack Middleware issue

Howdy, I'm having big trouble testing with rSpec's controller API. Right now I'm using a middleware authentication solution (Warden), and when I run the specs, the proxy added by the middleware is not there, and all the authentication tests are throwing NilPointerExceptions all over the place. It seems rSpec is not adding the middlewar...

A problem I'm having with modules

I'm trying to define a static variable and methods in a module that will be extended/used by numerous classes. The following example demonstrates: module Ammunition def self.included(base) base.class_eval("@@ammo = [bullets]") end def unload p @@ammo #<-- doesn't work end end class Tank include Ammunition @@...

I want to use EtherPad (or a clone). My site is running Ruby on Rails. API or local install?

I'd like to utilize an etherpad interface on my website. Two questions: 1) is there any site with an etherpad api that I could just call remotely? 2) if not, how much trouble is it to install scala and have the two run concurrently? Thanks ...

Rake aborted! Incorrect database name?

I was hoping to run some unit tests but this is what I am getting. The internets are silent on the issue. Rails 2.1 Let me know if there is any other info that would help. mike@sleepycat:~/projects/myapp$ rake test:units --trace (in /home/mike/projects/myapp) ** Invoke test:units (first_time) ** Invoke db:test:prepare (f...

Rails Browser Syntax Highlighting Plugin?

What is the standard Rails plugin for syntax highlighting (in a website admin panel for example, not for TextMate) that works right out of the box in a Rails project? ...

Find by category_id

In my search form I have a collection_select feature for picking a category. <% form_tag search_places_path do -%> <%= collection_select(:place, :category_id, Category.all, :id, :name) %> When I try this in the controller: @places = Place.find(:all, :conditions => ["category_id = ?", params[:category_id]]) I ...

rails restful filtering

I have an index action and I would like the user to be able to filter the results on the index page by clicking on "filter links" on the same page. There is a nice railcasts video that allows you to filter results by typing into a search box. I would like to filter results based on links the user clicks. How can I do this? Is there a w...

Rails accepts_nested_attributes_for child doesn't have parent set when validating

I'm trying to access my parent model in my child model when validating. I found something about an inverse property on the has_one, but my Rails 2.3.5 doesn't recognize it, so it must have never made it into the release. I'm not sure if it's exactly what I need though. I want to validate the child conditionally based on parent attri...

RoR routing problem. Calling custom action, but getting redirected to show action

I am working on a project in ruby on rails and I am having a very difficult time with a basic problem. I am trying to call a custom action in one of my controllers, but the request is somehow getting redirected to the default 'show' action and I cannot figure out why. link in edit.html.erb: <%= link_to 'Mass Text Entry', :action=>"crea...

Configuring and running Ruby-On-Rails migrations

Hi, I'm (completely) new to ROR and have got an application to maintain and upgrade. I've the source code and am trying to build database using db:migrate rake command. I've started using Aptana Studio for the development. When I run dg:migrate I get following errors: rake db:migrate (in G:/Projects/.../.../trunk) MissingSourceFile no s...

Rails: Proper work flow to shred XML data into relational SQL database

I have a Rails project and I used Migrations to setup the database schema (I'm using sqlite3). I have a XML file that I want to insert into my database. What's the best way to approach this? I'm thinking there's some Ruby script that I can write once and use to parse the XML file and insert it into my database, but intuitively it feels l...

Ruby equivalent for php function openssl_pkey_get_public

Hello all I have the php script where the password encoding done using the openssl: $key = openssl_get_publickey($certificate); openssl_public_encrypt($pass,$userPassCrypted,$key,OPENSSL_PKCS1_PADDING); openssl_free_key($key); Now I trying to make the same with ruby require 'openssl' cert = OpenSSL::X509::Certificate.new(certi...

"Was dirty" plugin for ActiveRecord?

I'm working on some code that uses a lot of after_save callbacks, and I remember seeing a plugin that allows the model.changes array to persist after a call to save. It would be a great help if I could just write if body_did_change? in my after_save calls, instead of having to hack together something with a before_save filter just to se...

generating excel documents with RUBY

I need to generate excel documents with ruby (from rails) on a Linux Machine. I know of Spreadsheet::Excel, but it doesn't support formulas, and uses a pretty old format.. Is there any other option, not necessarely free or opensource, that is a bit more powerful? thanks ...

How to use bundler (0.9.1.pre1) with Rails and CouchRest

I want to use the current version of bundler (there have been quite some changes from 0.8 to 0.9) to mange the gems of my Rails app. First I created a Gemfile in the root of the app folder and added all the needed gems to it. Then I placed (as recommended in the manual) the following code to my config/environment.rb: begin # Require t...

Rails Rake Tasks, output a message during and at the end.

Hi, I've made a rails rake task that uploads/crops/re-sizes (with paperclip) silly amounts of images. I wanted to know how to output a message to the terminal when it was running (e.g. chipolata.jpg processed) and at the end, it takes a good few minutes to run and a little feedback would be good. Thanks. ...