Hi Kevin - that makes sense. Where I am confused is that the position
column *is* being populated when the item is initially added to the
list. If I create a new Activity and add three items to it, looking
manually at the join table, the position column has 1,2,3, as
positions. So I don't see where nil is an issue. The problem is that
they do not update when dragged. That is when I get the "Unknown
Attribute: position" error, and the column has not updated - is still
1,2,3

On Jun 10, 9:30 pm, kevinpfromnm <[email protected]> wrote:
> position in list is relative.  can't adjust one's point in list based
> off a nil value.  that'd be my guess since you said the column was
> present.
>
> On Jun 10, 3:39 pm, Ronbo <[email protected]> wrote:
>
> > Ok, thanks.
>
> > I'm not sure either what you mean by this (referring to the position
> > column not updating:
>
> > (not available) means nil value IIRC.  since you had existing values,
> > you'll need to populate the values.
>
> > Since I get "unknown attribute: position", is the problem that the
> > unit model does not know where position is? Or is it some other issue?
>
> > On Jun 10, 5:35 pm, kevinpfromnm <[email protected]> wrote:
>
> > > that's what I meant.  so the position would be per activity.
>
> > > On Jun 10, 3:21 pm, Ronbo <[email protected]> wrote:
>
> > > > Thanks Kevin,
>
> > > > Not sure what you mean about scope to activity. I have
> > > > acts_as_list :scope => :activity on the join now.
>
> > > > On Jun 10, 2:27 pm, kevinpfromnm <[email protected]> wrote:
>
> > > > > (not available) means nil value IIRC.  since you had existing values,
> > > > > you'll need to populate the values.  oh, you'll also need to scope the
> > > > > acts_as_list to the activity as well
>
> > > > > On Jun 10, 8:49 am, Ronbo <[email protected]> wrote:
>
> > > > > > OK. I just added <view:unit_activity.position/> to the view and get
> > > > > > (Not Available) when I render the page.
>
> > > > > > In the unit_activity table, the position column is being populated
> > > > > > when the units are added to an activity, but not when reordered from
> > > > > > the acts_as_list view.
>
> > > > > > Could this be a permission or scope problem caused by 'position' 
> > > > > > being
> > > > > > on the join table?
>
> > > > > > Thanks,
>
> > > > > > On Jun 9, 5:28 pm, Ronbo <[email protected]> wrote:
>
> > > > > > > Yup. I have a 'position' column on the join table.
>
> > > > > > > On Jun 9, 5:06 pm, kevinpfromnm <[email protected]> wrote:
>
> > > > > > > > hmm... you've already done the migration after declaring the
> > > > > > > > acts_as_list?
>
> > > > > > > > On Jun 9, 2:46 pm, Ronbo <[email protected]> wrote:
>
> > > > > > > > > Thanks again. The tips are really appreciated.
>
> > > > > > > > > I added the hobo_reorder as shown below. The page now renders 
> > > > > > > > > properly
> > > > > > > > > (with the sortable-collection UI controls).
>
> > > > > > > > > class UnitsController < ApplicationController
> > > > > > > > >   hobo_model_controller
> > > > > > > > >   auto_actions :all
>
> > > > > > > > >   def reorder
> > > > > > > > >     hobo_reorder
> > > > > > > > >   end
> > > > > > > > > end
>
> > > > > > > > > The page now renders properly (with the sortable-collection UI
> > > > > > > > > controls), but moving a list item fails to update the 
> > > > > > > > > position with
> > > > > > > > > the following error:
> > > > > > > > > ActiveRecord::UnknownAttributeError (unknown attribute: 
> > > > > > > > > position):
>
> > > > > > > > > I have the position declared on the join relation:
> > > > > > > > >    has_many :unit_activities, :order => :position
>
> > > > > > > > > Is this the right place, or is there something else I need to 
> > > > > > > > > tweak to
> > > > > > > > > get this going?
> > > > > > > > > I'm getting closer...
>
> > > > > > > > > On Jun 9, 2:46 pm, kevinpfromnm <[email protected]> 
> > > > > > > > > wrote:
>
> > > > > > > > > > you need the method on the controller for it, I can't 
> > > > > > > > > > remember if it's
> > > > > > > > > > something special or just standard update methods.
>
> > > > > > > > > > On Jun 9, 12:41 pm, Ronbo <[email protected]> wrote:
>
> > > > > > > > > > > Hi Kevin,
>
> > > > > > > > > > > Do you mean something like:
>
> > > > > > > > > > > class Activity < ActiveRecord::Base
> > > > > > > > > > >    has_many :unit_activities, :order => :position
> > > > > > > > > > >    has_many :units, :through => :unit_activities
>
> > > > > > > > > > > ....
>
> > > > > > > > > > > class UnitActivity < ActiveRecord::Base
> > > > > > > > > > >    belongs_to :activity
> > > > > > > > > > >    belongs_to :unit
> > > > > > > > > > >    acts_as_list :scope => :activity
>
> > > > > > > > > > > ...
> > > > > > > > > > > class Unit < ActiveRecord::Base
> > > > > > > > > > >    has_many :unit_activities
> > > > > > > > > > >    has_many :activities, :through => :unit_activities
>
> > > > > > > > > > > class ActivityHints < Hobo::ViewHints
> > > > > > > > > > >   children :units
>
> > > > > > > > > > > This generates a <collection:units param/> tag for the 
> > > > > > > > > > > Activities show
> > > > > > > > > > > page. If I manually change it to 
> > > > > > > > > > > <sortable-collection:units param/>, I
> > > > > > > > > > > get the following error:
>
> > > > > > > > > > > undefined method `reorder_units_url'
>
> > > > > > > > > > > Am I missing the gist of what you mean, or am I missing a 
> > > > > > > > > > > step? Do I
> > > > > > > > > > > need to pass something to sortable-collection?
>
> > > > > > > > > > > Thanks,
>
> > > > > > > > > > > On Jun 9, 1:32 pm, kevinpfromnm <[email protected]> 
> > > > > > > > > > > wrote:
>
> > > > > > > > > > > > You want the acts_as_list and accessible on the join 
> > > > > > > > > > > > table, not the
> > > > > > > > > > > > end table.  that way, each item can be sorted per 
> > > > > > > > > > > > document.
>
> > > > > > > > > > > > On Jun 9, 9:08 am, Ronbo <[email protected]> wrote:
>
> > > > > > > > > > > > > Hi all,
>
> > > > > > > > > > > > > I am still very new to Hobo, and learning mostly 
> > > > > > > > > > > > > through trial and
> > > > > > > > > > > > > error. I have been creating small throw-away apps to 
> > > > > > > > > > > > > explore and test
> > > > > > > > > > > > > things out.
>
> > > > > > > > > > > > > I do have a serious app in mind though, and I am 
> > > > > > > > > > > > > trying to figure out
> > > > > > > > > > > > > how to implement a specific workflow in which users 
> > > > > > > > > > > > > will create new
> > > > > > > > > > > > > documents and add boilerplate text pieces to them 
> > > > > > > > > > > > > from a predefined
> > > > > > > > > > > > > set. Since documents will have many pieces and a 
> > > > > > > > > > > > > piece can belong to
> > > > > > > > > > > > > many documents, my first hunch is that I would use a
>
> > > > > > > > > > > > > has_many :through => x, :accessible => true
>
> > > > > > > > > > > > > sort of relationship, with the pieces as children of 
> > > > > > > > > > > > > the document
> > > > > > > > > > > > > model. Users could create a new doc and add the 
> > > > > > > > > > > > > pieces they want.
> > > > > > > > > > > > > Where I am having problems prototyping this is that 
> > > > > > > > > > > > > the pieces in the
> > > > > > > > > > > > > doc should be sortable. I've hunted through the hobo 
> > > > > > > > > > > > > and rails forums
> > > > > > > > > > > > > and can't find a recipe for how to make acts_as_list 
> > > > > > > > > > > > > work with a
> > > > > > > > > > > > > joined many-to-many sort of relationship.
>
> > > > > > > > > > > > > Is this possible? If so, is there a better way of 
> > > > > > > > > > > > > defining the
> > > > > > > > > > > > > relationship or some special magic to getting it 
> > > > > > > > > > > > > working through a
> > > > > > > > > > > > > join?
>
> > > > > > > > > > > > > Any hints are much appreciated.

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

Reply via email to