has_many, :through (again)

2 views
Skip to first unread message

johan pretorius

unread,
Dec 22, 2009, 6:44:56 AM12/22/09
to ActiveScaffold : Ruby on Rails plugin
Hi there,

I've tried the following solution (Rails 2.3.4 and the latest version
of ActiveScaffold), but get an error when trying to edit a record with
multiple associations.

Any ideas would be appreciated.

http://www.mail-archive.com/actives...@googlegroups.com/msg00272.html

ActionView::TemplateError (You have a nil object when you didn't
expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.<=>) on line #4 of vendor/
plugins/active_scaffold/frontends/default/views/
_form_association.html.erb:
1: <%
2: parent_record = @record
3: associated = column.singular_association? ? [parent_record.send
(column.name)].compact : parent_record.send(column.name).to_a
4: associated = associated.sort_by {|r| r.new_record? ? 99999999999 :
r.id} unless column.association.options.has_key?(:order)
5:
6: associated << column.association.klass.new if
column.show_blank_record? associated
7: -%>

vendor/plugins/active_scaffold/frontends/default/views/
_form_association.html.erb:4:in `sort_by'
vendor/plugins/active_scaffold/frontends/default/views/
_form_association.html.erb:4
vendor/plugins/active_scaffold/frontends/default/views/
_form.html.erb:10
vendor/plugins/active_scaffold/frontends/default/views/
_form.html.erb:2
vendor/plugins/active_scaffold/frontends/default/views/
_update_form.html.erb:44


thanks,

Johan

johan pretorius

unread,
Dec 24, 2009, 12:58:33 AM12/24/09
to ActiveScaffold : Ruby on Rails plugin
For the benefit of others that may have the same problem, it turned
out that the current version of ActiveScaffold handles HABTM out of
the box (with a default link table following the Rails convention, eg.
groups_users when dealing with users and groups). And very well, I may
add.

I've given up on has_many, :through for the time being (when using
ActiveScaffold), wasn't really required.

Reply all
Reply to author
Forward
0 new messages