#480 ✓resolved
Josh

find_owner_and_association method for has_many associations

Reported by Josh | August 5th, 2009 @ 04:47 AM | in Hobo 1.0 - Final

Could not set up an index_for action with a has_many through association.

I tracked down the problem to the find_owner_and_association method in lib/hobo/model_controller.rb

452: id = params["#{owner_association}_id"]

for a has_many association, the owner_association is plural, but the param is singular. One of them needs to be changed, not sure which way is better, I guess it should access the singular version.

Example:

class Group < ActiveRecord::Base

hobo_model # Don't put anything above this

has_many :members, :through => :memberships, :source => :user

has_many :memberships, :dependent => :destroy

...

class GroupsController < ApplicationController

hobo_model_controller

auto_actions :all

auto_actions_for :members, :index

This as it is doesn't work.

I added this as a temporary bug fix:

def index_for_member

params[:members_id] = params[:member_id] # bug fix

hobo_index_for(:members)

end

Let me know if you have any questions about any of that.

Thanks,

.....Josh.....

hobo (0.8.8)
Rails 2.3.2
ruby 1.8.7

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Pages