Fixing problems...

13 views
Skip to first unread message

ylluminate

unread,
Jun 24, 2011, 4:34:09 PM6/24/11
to Hobo Users
I just had an issue with a model where I backed out of it, or thought
I had with git. After rolling back, I ran `hobo g migration` without
a problem. Thinking things were fine, I began again to modify my
models for a many-to-many relationship. I can provide more details on
this if desired, however upon running `hobo g migration` again after
thinking I was done modifying the files, the system blew up with the
following error:
http://pastie.org/private/vkpaq9m2ue6n7lxyefdcrw

Now, I suppose since I just have the models done, I can just recreate
the hobo project from scratch and try not to make some apparent
mistake again, however I feel that that’s rather counterproductive.
Can someone advise me as to how to hunt down the source of an error
like this?

It happens also when I now simply attempt to run `rails s` so it
appears to be something fundamentally wrong, likely a mistake that I
can’t seem to trace. RubyMine is also not inspecting methods and
variables either now, so I’m lead to believe it is something either
from the rollback or my own mistake (perhaps a typo, however I've
scrubbed several times and see no detectable errors).


Would REALLY appreciate any pointers on this!

Bob Sleys

unread,
Jun 24, 2011, 5:33:37 PM6/24/11
to hobo...@googlegroups.com
I've seen that kind of error when not setting the mode name correctly,  IE running the generator and specifying the model as plural instead of singular.  It gets confused between the singular/plural versons.

Bob

ylluminate

unread,
Jun 24, 2011, 6:23:06 PM6/24/11
to Hobo Users
So in this case I created the model "city_county" which sits between
the city and county models. I initially had made a mistake and called
it cities_counties, but removed the files (all that were generated)
manually and redid it, which seemed to work, but then blew up as
indicated.

Further I wonder about this: I am seeing a problem that I had not
hitherto seen in RubyMine and I am lead to believe that something must
be wrong with the project or hobo from what it is reporting when
attempting to seek out generators:
http://pastie.org/private/bguk0jhglbobjbvfrg7w

This was not happening prior to this incident, so I'm thinking there's
something more at play here given this issue now on top of the other.


Thanks,

-George

ylluminate

unread,
Jun 25, 2011, 1:44:06 PM6/25/11
to Hobo Users
I could really use some input here as I at least figured out where it
is blowing up.

First, I got it back to where it was blowing up again and then started
stepping changes back out until I figured out that it is from two
models that I'm attempting to establish a many-to-many relationship
with.

I guess I should first explain the two models:
http://bit.ly/kDc8al

The models migrate just fine, but do explode when I put in "children":
city.rb Model: http://pastie.org/private/tnntwg3dupgay7ttwdqnq
county.rb Model: http://pastie.org/private/sxsllscttipn7ljjwu9oug
city_county.rb Model: http://pastie.org/private/voq80qpcmeqyefknonh6oq

However, when I attempt to add a city or view a city I had created
earlier, for example, the application returns the following error:
ActiveRecord::HasManyThroughAssociationNotFoundError in Cities#new
Showing controller: cities; dryml-tag: new-page where line #1 raised:
Could not find the association :city_counties in model City
Extracted source (around line #1):
0

And on the rails server console:
ActionView::Template::Error (Could not find the
association :city_counties in model City):
0 app/views/taglibs/auto/rapid/forms.dryml:6:in `block (3 levels) in
form__for_city'
app/views/taglibs/auto/rapid/forms.dryml:4:in `block (2 levels) in
form__for_city'
app/views/taglibs/auto/rapid/forms.dryml:4:in `block in
form__for_city'
app/views/taglibs/auto/rapid/forms.dryml:3:in `form__for_city'
app/views/taglibs/auto/rapid/pages.dryml:76:in `block (6 levels) in
new_page__for_city'
app/views/taglibs/auto/rapid/pages.dryml:75:in `block (5 levels) in
new_page__for_city'
app/views/taglibs/auto/rapid/pages.dryml:75:in `block (4 levels) in
new_page__for_city'
app/views/taglibs/auto/rapid/pages.dryml:66:in `block (3 levels) in
new_page__for_city'
app/views/taglibs/themes/clean/clean.dryml:2:in `block in
page_with_aaa82d3a9ca5'
app/views/taglibs/themes/clean/clean.dryml:1:in
`page_with_aaa82d3a9ca5'
app/views/taglibs/application.dryml:12:in `block in
page_with_a46705120a36'
app/views/taglibs/application.dryml:11:in `page_with_a46705120a36'
app/views/taglibs/auto/rapid/pages.dryml:63:in `block in
new_page__for_city'
app/views/taglibs/auto/rapid/pages.dryml:62:in `new_page__for_city'


Any thoughts here?



On Jun 24, 5:33 pm, Bob Sleys <bsl...@gmail.com> wrote:

ylluminate

unread,
Jun 25, 2011, 2:40:50 PM6/25/11
to Hobo Users
Okay, sorry about that. Inexperience with the has_many :through
apparently... Found that I needed to have a relationship with the
city_county model as well so that it would simply have a
"has_many :city_counties" before each of the has_many ____, :through
=> :city_counties for both the city.rb and county.rb models.

Now "children :properties, :counties" no longer blows up either.


-George

Matt Jones

unread,
Jun 25, 2011, 9:57:57 PM6/25/11
to hobo...@googlegroups.com

On Jun 25, 2011, at 2:40 PM, ylluminate wrote:

> Okay, sorry about that. Inexperience with the has_many :through
> apparently... Found that I needed to have a relationship with the
> city_county model as well so that it would simply have a
> "has_many :city_counties" before each of the has_many ____, :through
> => :city_counties for both the city.rb and county.rb models.

Yep. You may also want :dependent => :destroy on both of the plain has_manys, so that the join table (city_countries) records are cleaned up when an associated record is deleted.

--Matt Jones

ylluminate

unread,
Jun 25, 2011, 10:51:00 PM6/25/11
to Hobo Users
Will do, thanks. I was curious about that as I did not want it to
actually destroy the end of the chain for either of them. For
example, if a county is destroyed, I did not want it to destroy cities
attached to it and likewise for cities for counties. Apparently
destroy therefore only interacts with the intermediary table elements?

-George

ylluminate

unread,
Jun 25, 2011, 10:53:40 PM6/25/11
to Hobo Users
Okay, note for sanity, I think I see. You noted only on the plain
has_many's since it is only related to that join table. Thus the
negative result concern that I had is only pertinent to the second
relationship: "has_many :______, :through
=> :city_counties, :accessible => true"


-George



On Jun 25, 9:57 pm, Matt Jones <al2o...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages