activesupport

NoMethodError for time_zone_select in a form

I've set up my app exactly in line with the Railscasts Time Zone Episode 1 but when I run <%= f.time_zone_select :time_zone, ActiveSupport::TimeZone.us_zones %> I get this error NoMethodError in Users#new Showing app/views/users/new.html.erb where line #27 raised: You have a nil object when you didn't expect it! You ...

Use Rails 3's ActiveSupport core extensions outside rails

Hi guys. I'm having a problem using ActiveSupport's core extensions on a gem I am developing. I had it working with AS 2.3.8, but as soon as I wanted to port it to 3b4, the extensions stopped working and my test results are filled with lines such as: undefined method `blank?' for "something":String I've included it via gem "activesu...

cattr_accessor not working (outside rails) when active_support is required?

Hi guys, I'm not familiar with active_support, so bear with me! Fox's library allows searching via google's APIs, but it requires active support. i can't seem to get it working though! Any ideas? require 'rubygems' require 'active_support' require 'google_search' p GoogleSearch.web :q => "Hello World!" Gives me: NoMethodError: unde...

rake aborted! undefined method `text_area' for class `ActionView::Base'

Hi Folks, I am very confused by a sudden problem with running rake tasks: softwareclick:/myapp/current# rake my_task --trace (in /myapp/releases/20100621162444) ** Invoke my_task (first_time) ** Invoke environment (first_time) ** Execute environment rake aborted! undefined method `text_area' for class `ActionView::Base' /myapp/releases...

Rails: cattr_accessor and class variables

Running this code: module A def self.included(klass) klass.send(:cattr_accessor, :my_name) end def set_my_name_var @@my_name = 'A' # does NOT work as expected end def set_my_name_attr self.class.my_name = 'A' # works as expected end end class B include A cattr_accessor :my_other_name def set_my_other_...

Rails automatic class loading

Rails has a feature where models, controllers, views, libraries, etc. are automatically loaded when they are needed. This is especially helpful in development mode, where they get automatically reloaded as well. How do I tell Rails to perform automatic loading somewhere it doesn't expect to load files? Say, I create a folder app/addons ...

Rails ActiveSupport: How to assert that an error is raised?

I am wanting to test a function on one of my models that throws specific errors. The function looks something like this: def merge(release_to_delete) raise "Can't merge a release with itself!" if( self.id == release_to_delete.id ) raise "Can only merge releases by the same artist" if( self.artist != release_to_delete.artist ) #...

warning: getc is obsolete; use STDIN.getc instead

Hello, I'm having a problem with my rails application. When I type script/server I get the following error: /Users/admin/.gem/ruby/1.8/gems/activesupport-2.3.5/ lib/active_support/multibyte/unicode_database.rb:37: warning: getc is obsolete; use STDIN.getc instead This causes the application to hang and not respond. How can I...

How to fix difference in behavior of activesupport 3.0.0 compare to 2.x?

I am using Hash#to_xml in my Sinatra application. It did work till I moved to actviesupport 3.0.0 Is there a difference in usage of activesupport in 3.0.0? For example this works fine gem 'activesupport', '2.3.5' require 'active_support' {}.to_xml and gem 'activesupport', '3.0.0' require 'active_support' {}.to_xml generates: N...

Failed WATIR installation Server 2003

Hi all, I had to rebuild my box and I currently am unable to install Watir. gem install watir ERROR: Error installing watir: activesupport requires Ruby version >= 1.8.7. Which would be fine if Watir was able to use Ruby 1.8.7 . I am using ruby -v ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32] ge...

undefined method `to_json' for #<Hash:0x3d3cef0> (NoMethodError) in ActiveSupport 3

Did to_json get removed or something? ...

Rake 0.8.7 and ActiveSupport 3.0.1

Hello guys, I am running Ruby 1.9.2. I have rake 0.8.7 installed. However running rake inside a Rails application gives me the following: (in /usr/home/users/dimitar/Rails/spek) Could not find activesupport-3.0.1 in any of the sources Try running `bundle install`. So I go ahead and run bundle install again and everything looks good: ...

How to get TimeWithZone within rails3 unit/test

Hi, I'm trying to test a rails, application, and in one particular case, I need to create a TimeWithZone object inside my testcase. So I write sth like this: started_at = ActiveSupport::TimeWithZone(started_at, Time.zone) only to get an error: NoMethodError: undefined method `TimeWithZone' for ActiveSupport:Module I tried requiri...

ActiveSupport requires Ruby version >= 1.8.7 on Ubuntu

Hi, I'm currently setting up a new server, and started off with an Ubuntu 8.04 image with a version of Ruby and Rails already preinstalled (I thought it would be easier), and after getting my app running (with a few gems installed), the command line is throwing a wobbly, and trying to install the "Paperclip" gem, is giving the following ...

Active Record to_json\as_json on Array of Models

First off, I am not using Rails. I am using Sinatra for this project with Active Record. I want to be able to override either to_json or as_json on my Model class and have it define some 'default' options. For example I have the following: class Vendor < ActiveRecord::Base def to_json(options = {}) if options.empty? super ...

Custom Inflections not working on rails3?

I'm using Rails (3.0.1) and have the following code in initializers/inflections.rb ActiveSupport::Inflector.inflections do |inflect| inflect.irregular('nursery', 'nurseries') end From the console I'm getting: "nursery".pluralize => "nurseries" "nurseries".singularize => "nurseries" I should be getting: "nurseries".singularize => ...

Rails times oddness : "x days from now"

Hi all. when users sign up to one of my sites for a free trial, i set their account expiry to be "14.days.from_now". Then on the home page i show how many days they have remaining, which i get with: (user.trial_expires - Time.now)/86400 (because there are 86400 seconds in a day, ie 60 * 60 * 24) The funny thing is, this comes out ...