Upgrading from 0.8.3 to 0.9.103 -- `owner_routes': Hob routing error -- can't find reverse association

28 views
Skip to first unread message

Me

unread,
Jan 21, 2010, 5:01:11 PM1/21/10
to Hobo Users

Greetings. I built an app sometime back with Hobo 0.8.3 and rails
2.1.1 on Ubuntu Hardy. That machine is now defunct. I'm trying to re-
deploy it with 0.9.103 on an Ubuntu Jaunty machine with rails 2.3.5.
I've overcome a few gotchas, but this one has me stumped:

model_router.rb:176:in `owner_routes': Hob routing error -- can't find
reverse association for Archive#workspace (e.g. the :has_many that
corresponds to a :belongs_to) (HoboError)

From searching the archives, the solution each time was to correct
errors in the association itself. In my case, I can't find what I did
wrong. At the same time, it used to work. This is the association
that used to be valid:

archive.rb
belongs_to :workspace

workspace.rb
has_many :archives, :foreign_key =>
"workspace_id"

In archive_controller.rb :
auto_actions :all, :except => :index
auto_actions_for :workspace, [:new]

I tried adding the FK to the archive.rb belongs_to half, but it didn't
help. I also tried downgrading to rails 2.2.2, but got the same error.
Does anyone know what I did wrong?

Thanks!

kevinpfromnm

unread,
Jan 21, 2010, 5:12:29 PM1/21/10
to Hobo Users
Add the :accessible => true to the association

Matt Jones

unread,
Jan 21, 2010, 5:15:39 PM1/21/10
to hobo...@googlegroups.com

Really weird - I can't see anything that would be causing problems. Is
there a particular reason why you're specifying :foreign_key
on :archives? The value you're passing is the same as what Rails would
select by default.

--Matt Jones

Me

unread,
Jan 21, 2010, 6:15:46 PM1/21/10
to Hobo Users
Kevin: Thanks for the tip. adding accessible => true enabled me to
migrate the DB where I couldn't before.

Matt: I put the FK on archives because I was grasping at straws.

Here's where it gets REALLY weird. After migrating the DB I fired up
Webrick => same error. I decided to REALLY grasp at straws and
install Apache2 / Passenger [ to go with plain old ruby -- not REE ].
I was able to pull up the site just fine with Apache after that. For
giggles, I commented out the accessible => true part, and it still
loads with Apache/Pass, but still not with Webrick. I was also able
to migrate the DB with it commented out. FWIW, I also recently did
the tutorial, and found flakey results when I ran it with Webrick,
i.e. transient errors that prevented it from loading at all,
sometimes. I'm not sure what to make of all that, except to skip
webrick.

Now that I can pull up the site, I see that the auto_actions_for
declaration doesn't automatically give me the inline forms, i.e.
create a new archive for the workspace. I just got the h2 headline
and a save button, but no fields. From looking at the docs, I see
that the dependent => :destroy declaration is gone in favor or
viewHints. I erased the old and created the following file in a dir
called app/viewhints:

class WorkspaceHints < Hobo::ViewHints

children :playlist, :archive

end

I did the same for the other models. Still, no working in line forms.
Still just a headline and a save button. There's still ample room for
me to root through the docs on this. At the same time, I thought I'd
ask if you have any hints?

Thanks for the help! Paul

kevinpfromnm

unread,
Jan 21, 2010, 6:27:37 PM1/21/10
to Hobo Users
yeah, either thin or mongrel but don't go webrick.

Owen Dall

unread,
Jan 21, 2010, 6:32:37 PM1/21/10
to hobo...@googlegroups.com
Hi Paul,
 
It would be helpful for others learning to put your code for review in a gist at http://gist.github.com.  I find it a lot easier to follow, and then we have a place to go to see the formatting and highlighted code..
 
I also encourge all to use Jing to do short screencasts when several steps are involved.  
 
 
IMHO a picture is worth 1,000 words, a move is worth 10,000.
 
 
-Owen

 
--
You received this message because you are subscribed to the Google Groups "Hobo Users" group.
To post to this group, send email to hobo...@googlegroups.com.
To unsubscribe from this group, send email to hobousers+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.




--
Thanks,

Owen

Owen Dall
Barquin International
410-991-0811

Matt Jones

unread,
Jan 21, 2010, 7:16:17 PM1/21/10
to hobo...@googlegroups.com

On Jan 21, 2010, at 6:15 PM, Me wrote:
>
> class WorkspaceHints < Hobo::ViewHints
>
> children :playlist, :archive
>
> end
>
> I did the same for the other models. Still, no working in line forms.
> Still just a headline and a save button. There's still ample room for
> me to root through the docs on this. At the same time, I thought I'd
> ask if you have any hints?
>

99% sure that the things declared in 'children' need to match the
associations on Workspace - so :playlists, :archives

--Matt Jones

Matt Jones

unread,
Jan 21, 2010, 7:22:14 PM1/21/10
to hobo...@googlegroups.com

On Jan 21, 2010, at 6:15 PM, Me wrote:
> I did the same for the other models. Still, no working in line forms.
> Still just a headline and a save button. There's still ample room for
> me to root through the docs on this. At the same time, I thought I'd
> ask if you have any hints?
>

Also note that if you want an inline form, you'll need to have an
auto_actions_for declaration like this:

auto_actions_for :workspace, [:create]

as the code in pages.dryml.erb is looking for a missing
new_for_workspace and a present create_for_workspace; having the :new
auto-action will yield a link instead.

--Matt Jones

Me

unread,
Jan 21, 2010, 9:24:39 PM1/21/10
to Hobo Users
All: Thank you for the help. It's very encouraging.

Matt: thanks for the tips.

Owen: I'm getting with the times. Here's the gist w/ the relevant
model / controller bits. Also the tags and output.

http://gist.github.com/283438

What it should [ used to ] do is create a form that enables a user to
add a video [ playlistItem] to his playlist. The actual generated
form leaves the field set blank, making it impossible to select from
the available videos. I seem to remember it populated a select box
with video.title displayed -- I'm not sure how it got that from
"video" as the only field-list item.


Thanks! Paul

Owen Dall

unread,
Jan 21, 2010, 9:48:36 PM1/21/10
to hobo...@googlegroups.com
Cool. makes it easier on the old eyes...

-Owen

--
You received this message because you are subscribed to the Google Groups "Hobo Users" group.
To post to this group, send email to hobo...@googlegroups.com.
To unsubscribe from this group, send email to hobousers+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.

Owen Dall

unread,
Jan 21, 2010, 10:12:18 PM1/21/10
to hobo...@googlegroups.com
Whoops.  Didn't see your "Archive" or "Workspace" model files...

On Thu, Jan 21, 2010 at 9:24 PM, Me <haman...@yahoo.com> wrote:
--
You received this message because you are subscribed to the Google Groups "Hobo Users" group.
To post to this group, send email to hobo...@googlegroups.com.
To unsubscribe from this group, send email to hobousers+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.

Owen

unread,
Jan 21, 2010, 10:57:34 PM1/21/10
to Hobo Users
Here is what I have so far:

http://screencast.com/t/ZWYxMTA2MG

I think a use case explaining the intended flow would be useful to
all...

-Owen

> > hobousers+...@googlegroups.com<hobousers%2Bunsu...@googlegroups.com>

Owen

unread,
Jan 22, 2010, 6:25:51 AM1/22/10
to Hobo Users
Another screen shot:

http://screencast.com/t/NjBiOWEyM

Is this what you are looking for?

Owen

unread,
Jan 22, 2010, 6:34:32 AM1/22/10
to Hobo Users
See the code and comment:

http://gist.github.com/283700

Note I didn't use any view hints, and the associated name for the
Playlistitem class is the table playlistitems.

Not sure if this is what you were looking for.
-

Me

unread,
Jan 22, 2010, 12:34:44 PM1/22/10
to Hobo Users
Owen: thanks for the help. I'll dig into your examples.

I setup the app so that you can see it at: http://gnostic.dnsdojo.com:8080/

You can login with user: admin pwd: password

On the frontpage, click on the link in the middle that says "go to my
workspace." Hopefully, it won't blow up.

Background:

About a year ago, a friend of mine was working on a project. I used
his docs to create a demo. His project was aimed at stroke survivors
that needed to recover their speech. He had access to content that
essentially showed closeups of peoples lips as they said certain
phrases. The idea is to enable them to re-connect the sound with the
lip movements that make that sound. A big part of the project was to
help people that had run out of savings and insurance benefits --
therapy is otherwise expensive.

As I mentioned, it used to work. My motivation right now is to to show
it as a demo. I'd also like to get re-acquainted with hobo.

At the time, I was new to the concept of RIAs. I did it with iFrames
[ never again! ]. I'm thinking it may be easier to just use
form_assistant to crank out the forms.

Cheers!

Me

unread,
Jan 22, 2010, 1:06:49 PM1/22/10
to Hobo Users
HI Owen:

At the moment, I'm just trying to get playlist and playlistItems
working. I was missing a couple of things from the example. First, I
didn't have accessible => true. Second, I was missing the has_many on
video. Sadly still no joy.

I'm gonna create a blank hobo app, and paste in pieces as I go. I'll
report back the results in a couple hours.

Thanks again!

Paul


On Jan 22, 3:34 am, Owen <od...@barquin.com> wrote:

Chris Sleys

unread,
Jun 13, 2012, 3:12:29 PM6/13/12
to hobo...@googlegroups.com
Hey I am on version 1.4.0 pre release and am getting a similar error. I tryed adding the :accessible => true as well as experimented with the :creator and :foreign_key tags with no luck. Maybe I'm missing something obvious but here is the relevant code and error message.

Thanks in advance for any help or suggestions you can offer,
Chris Sleys

 `block in owner_routes': Hob routing error -- can't find reverse association for Hour#owner (e.g. the :has_many that corresponds to a :belongs_to) (Hobo::Error)

class Hour < ActiveRecord::Base

  hobo_model # Don't put anything above this

  fields do
    hours_worked    :decimal
    date            :date
    comments        :text
    timestamps
  end

  belongs_to :project, :inverse_of => :hours
  belongs_to :work_code, :inverse_of => :hours
  belongs_to :owner, :class_name => "User", :creator => true, :inverse_of => :hours, :accessible => true, :dependent => :destroy 
  
  # --- Permissions --- #

  def create_permitted?
    acting_user.signed_up?
  end

  def update_permitted?
    acting_user.administrator?
    owner_is? acting_user
  end

  def destroy_permitted?
    acting_user.administrator?
    owner_is? acting_user
  end

  def view_permitted?(field)
    owner_is? acting_user
  end

end


class User < ActiveRecord::Base

  hobo_user_model # Don't put anything above this

  fields do
    name          :string, :required, :unique
    email_address :email_address, :login => true
    administrator :boolean, :default => false
    timestamps
  end

  # This gives admin rights and an :active state to the first sign-up.
  # Just remove it if you don't want that
  before_create do |user|
    if !Rails.env.test? && user.class.count == 0
      user.administrator = true
      user.state = "active"
    end
  end

  def new_password_required_with_invite_only?
    new_password_required_without_invite_only? || self.class.count==0
  end
  alias_method_chain :new_password_required?, :invite_only

  # --- Signup lifecycle --- #

  lifecycle do

    state :invited, :default => true
    state :active

    create :invite,
           :available_to => "acting_user if acting_user.administrator?",
           :subsite => "admin",
           :params => [:name, :email_address],
           :new_key => true,
           :become => :invited do
       UserMailer.invite(self, lifecycle.key).deliver
    end

    transition :accept_invitation, { :invited => :active }, :available_to => :key_holder,
               :params => [ :password, :password_confirmation ]

    transition :request_password_reset, { :active => :active }, :new_key => true do
      UserMailer.forgot_password(self, lifecycle.key).deliver
    end

    transition :reset_password, { :active => :active }, :available_to => :key_holder,
               :params => [ :password, :password_confirmation ]

  end

  def signed_up?
    state=="active"
  end
  
  has_many :hours, :inverse_of => :owner, :accessible => true
  children :hours

  # --- Permissions --- #

  def create_permitted?
    # Only the initial admin user can be created
    self.class.count == 0
  end

  def update_permitted?
    acting_user.administrator? ||
      (acting_user == self && only_changed?(:email_address, :crypted_password,
                                            :current_password, :password, :password_confirmation))
    # Note: crypted_password has attr_protected so although it is permitted to change, it cannot be changed
    # directly from a form submission.
  end

  def destroy_permitted?
    acting_user.administrator?
  end

  def view_permitted?(field)
    true
  end
end



Thanks,
Chris Sleys

Bryan Larsen

unread,
Jun 14, 2012, 11:35:15 AM6/14/12
to hobo...@googlegroups.com
Hmmm, it looks like you're doing it correctly.

Could you try using the current github master rather than the latest
gem? Just add :git => "git://github.com/tablatom/hobo.git" to the
hobo gems in your bundle, and remove the version option.

thanks,
Bryan
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/S9iyXiuqKnUJ.
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to
> hobousers+...@googlegroups.com.

Chris Sleys

unread,
Jun 14, 2012, 4:14:53 PM6/14/12
to hobo...@googlegroups.com
Thanks for the reply. Unfortunately, that had no effect.
Reply all
Reply to author
Forward
0 new messages