On 2 March 2011 15:08, David Kahn <dk@structuralartistry.com> wrote:
> ...
> Thanks Colin, here are the models and tables. Also to be sure went in to db
> console and verified the actual table names just in case something went
> awry. Also at bottom are the three rspec/shoulda errors. I have to be doing
> something wrong but if I am I don't see it.
>
> class XpJurisdictionState < ActiveRecord::Base
> has_many :xp_jurisdiction_taxes
> end
>
> class XpJurisdictionTax < ActiveRecord::Base
> belongs_to :account_subcode
> belongs_to :xp_jurisdiction_states
that should be :xp_jurisdiction_state. It belongs to one state so singular.
> end
>
> create_table "xp_jurisdiction_states", :force => true do |t|
> t.string "state_code"
> t.string "state"
> t.string "billing_item"
> t.string "billing_memo"
> t.datetime "created_at"
> t.datetime "updated_at"
> end
>
> create_table "xp_jurisdiction_taxes", :force => true do |t|
> t.integer "xp_jurisdiction_state_id"
> t.integer "account_subcode_id"
> t.decimal "tax"
> t.datetime "created_at"
> t.datetime "updated_at"
> end
>
> public | xp_jurisdiction_states | table | postgres
> public | xp_jurisdiction_states_id_seq | sequence | postgres
> public | xp_jurisdiction_taxes | table | postgres
> public | xp_jurisdiction_taxes_id_seq | sequence | postgres
>
>
> 1) AccountSubcode
> Failure/Error: it { should have_many(:xp_jurisdiction_taxes) }
> NameError:
> uninitialized constant AccountSubcode::XpJurisdictionTaxis
If you run a console and type
"tax".pluralize you will get "taxes" which is correct. However on
rails 3.0.5 if I type "taxes".singularize I get taxis which is not
what you want. I assume it is using the same rule as would apply for
axis and axes. The solution is to specify your own rules for your
xp_jurisidiction_tax and taxes and then you should be ok.
> # ./spec/models/account_subcode_spec.rb:16:in `block (2 levels) in <top
> (required)>'
>
> 2) XpJurisdictionState
> Failure/Error: it { should have_many(:xp_jurisdiction_taxes) }
> NameError:
> uninitialized constant XpJurisdictionState::XpJurisdictionTaxis
> # ./spec/models/xp_jurisdiction_state_spec.rb:4:in `block (2 levels) in
> <top (required)>'
>
> 3) XpJurisdictionTax
> Failure/Error: it { should belong_to(:xp_jurisdiction_states) }
Again should be singular, so that explains that problem I think.
Colin
> Expected XpJurisdictionTax to have a belongs_to association called
> xp_jurisdiction_states (XpJurisdictionTax does not have a
> xp_jurisdiction_states_id foreign key.)
>
>
>
>>
>> Colin
>>
>> >
>> >
>> > On Tue, Mar 1, 2011 at 5:37 PM, David Kahn <dk@structuralartistry.com>
>> > wrote:
>> >>
>> >> I have a model 'xp_jurisdiction_taxes' which rails (3) created
>> >> correctly.
>> >>
>> >> Another model 'xp_jurisdiction_states' has many :xp_jurisdiction_taxes.
>> >>
>> >> In my spec I am using a shoulda helper to test the association but get
>> >> the
>> >> following error. BTW, greped the whole project just in case and the
>> >> string
>> >> 'taxi' exists nowhere.
>> >>
>> >> 1) XpJurisdictionStates
>> >> Failure/Error: it { should have_many(:xp_jurisdiction_taxes) }
>> >> NameError:
>> >> uninitialized constant XpJurisdictionState::XpJurisdictionTaxis
>> >> # ./spec/models/xp_jurisdiction_states_spec.rb:4:in `block (2
>> >> levels)
>> >> in <top (required)>'
>> >>
>> >> Not sure if this is a rails or shoulda issue (I am starting to think it
>> >> is
>> >> shoulda). Any input?
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Ruby on Rails: Talk" group.
>> > To post to this group, send email to rubyonrails-talk@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > rubyonrails-talk+unsubscribe@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/rubyonrails-talk?hl=en.
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ruby on Rails: Talk" group.
>> To post to this group, send email to rubyonrails-talk@googlegroups.com.
>> To unsubscribe from this group, send email to
>> rubyonrails-talk+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-talk?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment