All,

Can anyone see what's happening here?

================== migration =======================
class CreateGreetings < ActiveRecord::Migration
  def self.up
    create_table :greetings do |t|
      t.string :greet
      t.string :language
      t.integer :count

      t.timestamps
    end
  end

  def self.down
    drop_table :greetings
  end
end
================== greeting.rb =============================
class Greeting < ActiveRecord::Base
  after_initialize :check_greet
  validates_uniqueness_of :count

  def check_greet
    self.language = lanugage.capitalize
  end
end
=================== greeting.yml ==========================
hello:
  greet: howdy
  language: english
  count: 44

hola:
  greet: hola, que tal
  language: spanish
  count: 55

=================== greeting_test.rb ========================
require 'test_helper'

class GreetingTest < ActiveSupport::TestCase
  # Replace this with your real tests.
  test "uniqueness of count" do
    gg = Greeting.new(:language => 'esperanto', :count => 
greetings(:hello).count)
    assert !gg.valid?
  end
end
=========================================================

When I run 'rake test:units' on this it blows up when getting to the 
after_initialize
procedure, claiming there is no method 'language' for the Greeting class.
I'm having this issue in a larger app, but I've tried to pare this down to 
the minimum
that reproduces the problem.

Is this a bug in rails, or am I missing something?

Regards,

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/hxqM0KZoDbUJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to