ruby-on-rails

WARNING: RubyGems 1.2+ index not found for: RubyGems will revert to legacy indexes degrading performance.

WARNING: RubyGems 1.2+ index not found for: RubyGems will revert to legacy indexes degrading performance. If anyone can walk me through this problem I will give them $50.00 I've exhausted google, have reinstalled everything. All i want to to is gem install ... that's it ...

(J)Ruby full locales/localisation/cultureInfo support

Hi, Does (J)Ruby support such things like Calendar in Java or CultureInfo in .NET? I want to be able to write code in Ruby similar to this: locale = Locale.new("en-GB") date1 = "30/12/2000".to_date(locale) locale = Locale.new("en-US") date2 = "12/30/2000".to_date(locale) Locale.current = "ru-RU" date2 = "30.12.2000".to_date # uses t...

Rails Changing Polymorphic Type Of An Object

We have a parent model Vehicle that is inherited to make classes Car, Truck, SUV. In our form, we allow the user to edit the data for a bunch of Vehicles, and one of the attributes for each vehicle is a select menu for "type". The HTML attribute is named vehicle_type and updates the actual Polymorphic type attribute in the Vehicle Model:...

Ruby on Rails: Passing argument to singleton

I have a Rails app that repeatedly talks to another Web server through a wrapper, and I'd like to stick the wrapper in a Singleton class so it's not recreated for every request. Easy enough, I thought: class AppWrapper < Wrapper include Singleton end ... wrapper = AppWrapper.instance "url" Only it doesn't work: wrong number of arg...

how to detect whether my rails is running in migration or not in environment.rb

any easy way to detect it? I want to skip some codes in envirmonment.rb when doing migration rake. ...

How to add a class to a render :partial => @collection on every 4th item?

Let's say I have 16 results On every 4th item I need to add a class "no-margin" (because every item on the left needs a margin right to create spacing but the last one doing that would break the layout, thus the need for this). What's the best way to do this? I have it very rails-like right now. render :partial => @collection _colle...

jQuery UI Dialog Buttons Not Responding to click_button or selenium.click in Selenium/Webrat

Has anyone been able to get the jQuery UI Dialog buttons to respond to click_button or selenium.click? I can't seem to be able to get this to work. Basically, I'm trying to test a form in a jQuery UI Dialog in a Rails app using Cucumber/Webrat/Selenium. I have a page with many table rows, and each row on click fires off a dialog box w...

Recommendations for a captcha on Ruby on Rails

I'd like to implement a captcha in a Rails project for a form submission, but I'm not sure what to go with. I'm inclining towards simplicity of implemention, and reliability when in use, over it being too sophisticated, as my application doesn't require too high a level of security. Anyone have any recommendations? thanks ...

Error creating a new survey as the associated model(s) are invalid (questions)

Hi, I have a survey as part of an application I'm building. The user can create a survey and specify questions dynamically (can have as many as they want), so I've used an associated model with: #survey.rb has_many :survey_questions, :dependent => :destroy has_many :survey_answers, :dependent => :destroy after_update :save_sur...

Table cell border

Hi guys, This is the 2x2 table I need to generate: r1c1 r1c2 r2c1 r2c1 ---- In other words I should print the bottom border of the bottom right cell. This is my code: show.pdf.prawn #This is a two dimensional array: my_array = [["r1c1","r1c2"],["r2c1",Prawn::Table::Cell.new(:text => "r2c2", :border_width => 1 , :borders => ...

Is it possible to see via which child class was a parent's static method called in Java?

A little background first. I am looking into the possibility of implementing Ruby's ActiveRecord in Java as cleanly and succinctly as possible. To do this I would need to allow for the following type of method call: Person person = Person.find("name", "Mike"); Which would resolve to something like: ActiveRecord.find(Person.class, "na...

Sharing Uploaded Files between multiple Rails Applications

I have multiple applications (an admin application, a "public"/non-admin application and a web service application) that all share a single database. I've gotten the applications to share models and other code where appropriate, so I don't have multiple copies of the same code in each. However, the one task that I've yet to configure...

default scope in older rails versions

afternoon all. i am working on a project written on rails 2.1 in newer versions we can use a rather cool method to create a default scope like so default_scope :order => 'title ASC' how can the same/similar effect be achieved without upgrading the rails version? ...

Consuming a SOAP Rails Webservice doesn't work in Delphi 2009 but was Ok in Delphi 2006

Hi, I have a soap webservice written in RubyOnRails and a client written in Delphi. The client and server comunicate fine using Delphi 2006, but compiling with the newer Delphi 2009 causes the Rails server to "crash". This is the request (generated by built in THTTPRIO): <?xml version="1.0"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http:/...

Best way for smart-paginated-ajax tables in Rails

I'd like to be able to DRY-ly and intelligently set up my Rails controllers so that I can effortlessly use paginated tables of data on various pages. Let me clarify. I already use will_paginate + a custom plugin that I wrote which acts as a table-view creator. This combination works perfectly for "index" actions which simply show one ...

Xcode save code folding?

I know it's not directly related to programming, but what better place then stackoverflow right? So code folding is an awesome feature which I love, but does anyone know if there is a way to get Xcode to remember where you have certain sections collapsed whenever you open a file? BTW, I'm coding ruby on rails using git version control...

Rails Routing: what is the difference between :conditions and :requirements in routing?

When should I use :conditions or :requirements in rails routing? Here are two examples: :conditions map.connect "/foo/:view/:permalink", :controller => "foo", :action => "show", :view => /plain|fancy/, :permalink => /[-a-z0-9]+/, :conditions => { :method => :get } end :requirements map.connect 'posts/index/:page', ...

Rails plugin require issues

Hi! I have a problem creating a Rails plugin, lets call it Mplug. The plugin is pretty much only a rake task, but with a library that the rake task uses. The problem is to require files. Lets say that this is the rake task: namespace :mplug do task :create do Mplug::Indexer.new end end This will not recognize the constant Mp...

How to disable default asset timestamps for some assets in rails?

There are some image assets on my site that will always remain static, and therefore do not need the timestamp that gets appended to the images. Is there a way to not append the timestamps for certain assets? ...

Why doesn't MyModel.all.each{|m| m.destroy} work as expected ?

I want to clear a table in my railsapp , without dropping the database and migrating... MyModel.all.each{|m| m.destroy} I would expect this code to delete every record in the my_model table, but this is not happening... using Rails 2.3.4 + MySQL 5.1 EDIT: the issue was based on the plugin better_nested_set which didn't allow me to d...