Hi Phillip,
Thanks for expressing an interest in my problem.
What does the migration for portfolios look like?
class CreatePortfolios < ActiveRecord::Migration
def self.up
create_table :portfolios do |t|
t.string :symbol
t.string :name
t.timestamps
end
end
def self.down
drop_table :portfolios
end
end
How is it failing? What is it doing?
I click on "New portfoilo", enter a three-letter Symbol "XXX" and
click "Create".
That yields the response "Portfolio was successfully created." and
displays the Symbol and Name (the latter being blank).
I click "Back" and see the new (XXX) Symbol and its (blank) Name
displayed, along with other pairs I've entered.
What are you expecting?
I repeat this process and see another instance of XXX. That' violates
the uniqueness declaration in the following specification:
class Portfolio < ActiveRecord::Base
before_save :uppercase_data
def uppercase_data
self.symbol.upcase!
end
validates_presence_of :symbol
validates_length_of :symbol, :maximum=>5, :message=>"exceeds %d
characters"
validates_uniqueness_of :symbol
validates_format_of :symbol, :with => /^[a-zA-Z\d]+$/, :on
=> :create,
:message => "(Character other than letter or digit found, e.g a
blank)"
end
Is there an error message?
No. But there should be an error message indicating the the second
XXX could not be added because it's not unique.
Please let me know if there's anything else I can provide.
I'm going to get my personal website under my ISP's aegis re-
established so I can just post my code so that any interested party
can simply view whatever part he wishesl
Sincerely,
Richard