Using a Nested scaffold instead of a subform

143 views
Skip to first unread message

Jeff Surrett

unread,
Jan 5, 2011, 6:08:27 PM1/5/11
to ActiveScaffold : Ruby on Rails plugin
Is there a way of having nested scaffolds appear for the associated
tables instead of subforms in an update form? I tried to embed a
scaffold in a form override but when I update a record in the embedded
scaffold, it takes me the main page for that scaffold instead of
updating inline. I am using Vhochstein's rails 3 branch of AS.

vhochstein

unread,
Jan 6, 2011, 2:36:29 AM1/6/11
to ActiveScaffold : Ruby on Rails plugin
Hi,

I ve never tried, but it is an interesting idea.
What is your specific requirement for such a feature?

--
Volker

Jeff Surrett

unread,
Jan 6, 2011, 9:48:53 AM1/6/11
to ActiveScaffold : Ruby on Rails plugin
I would like to have the user be able to edit a form which would
include nested active scaffolds for each has_many association instead
of using subforms like it does currently. I think that using nested
scaffolds gives a more consistent look and feel and more flexibility
such as sorting of records, using action_links on the group of records
like the new batch action and other custom actions.

The important part for this to work, is that any actions performed on
the nested (embedded) scaffold would just update (replace) that
scaffold inline similar to how it works with nested scaffolds now.

vhochstein

unread,
Jan 7, 2011, 12:32:35 AM1/7/11
to ActiveScaffold : Ruby on Rails plugin
Hi Jeff,

Well, let s see how far we get. Currently, it seems that UJS is nt
working in your nested scaffold. Can you please post what you did so
far?

--
Volker

Michael Latta

unread,
Jan 16, 2011, 12:18:14 PM1/16/11
to actives...@googlegroups.com
I am interested in this as well. If you get it working please post your results.

Michael

> --
> You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group.
> To post to this group, send email to actives...@googlegroups.com.
> To unsubscribe from this group, send email to activescaffol...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en.
>

Jeff Surrett

unread,
Jan 21, 2011, 11:41:35 PM1/21/11
to ActiveScaffold : Ruby on Rails plugin
I was away for a while but now I am back. sorry for the delay.

I have created a form override for families called _form.html.erb
containing:

<code>
<ol class="form" <%= 'style="display: none;"' if columns.collapsed -
%>>
<% column = active_scaffold_config.columns[:account_name] -%>
<li class="form-element <%= 'required' if column.required? %> <%=
column.css_class unless column.css_class.nil? %>">
<%= render :partial => form_partial_for_column(column), :locals
=> { :column => column } -%>
</li>
</ol>

<%= render :active_scaffold => "family_contacts", :constraints =>
{ :family_id => @record.id } %>

</code>

When I edit a family record, the form opens as expected with a field
from the family table and an embedded form of family_contacts which
belongs_to family (with the appropriate has_many relationship in
family). When I try to edit a family contact record, the inline form
appears as expected and allows me to make changes to its fields, but
when I click the update button, it updates the record but then gets
"Redirected to http://localhost:3000/family_contacts?eid=be3a15b3b3877d869549f3505e42fc76"

I would like for the update to occur and remain on the current page.

vhochstein

unread,
Jan 25, 2011, 3:43:28 AM1/25/11
to ActiveScaffold : Ruby on Rails plugin
Hi Jeff,

I ve reproduced your issue on my side. Seems that UJS is nt working,
however unfortunetly I cannot tell you why so far.

You may try instead a slightly different approach.
Instead of calling render :active_scaffold... in _form.html.erb,
you may override _update_form.rb in your controller view directory:
<%= render :super %>
<%= render :active_scaffold => "family_contacts", :constraints =>
{ :family_id => @record.id } %>

Hope that helps.

--
Volker

On Jan 22, 5:41 am, Jeff Surrett <jsurr...@gmail.com> wrote:
> I was away for a while but now I am back. sorry for the delay.
>
> I have created a form override for families called _form.html.erb
> containing:
>
> <code>
> <ol class="form" <%= 'style="display: none;"' if columns.collapsed -
> %>>
>         <% column = active_scaffold_config.columns[:account_name] -%>
>         <li class="form-element <%= 'required' if column.required? %> <%=
> column.css_class unless column.css_class.nil? %>">
>             <%= render :partial => form_partial_for_column(column), :locals
> => { :column => column } -%>
>         </li>
> </ol>
>
> <%= render  :active_scaffold => "family_contacts", :constraints =>
> { :family_id => @record.id } %>
>
> </code>
>
> When I edit a family record, the form opens as expected with a field
> from the family table and an embedded form of family_contacts which
> belongs_to family (with the appropriate has_many relationship in
> family). When I try to edit a family contact record, the inline form
> appears as expected and allows me to make changes to its fields, but
> when I click the update button, it updates the record but then gets
> "Redirected tohttp://localhost:3000/family_contacts?eid=be3a15b3b3877d869549f3505e4..."

Yves-Emmanuel Jutard

unread,
Jan 25, 2011, 6:48:55 AM1/25/11
to actives...@googlegroups.com
Hello,

I have a data structure like that :
* Post (post/posts) which "has_many" post_meta_datas
* PostMetaData (post_meta_data/post_meta_datas) which "belongs_to" post

I write a simple controller for using activescaffold, and when I list my
posts, I get a nasty error "uninitialized constant Post::PostMetaDatum"

It looks like (I think...) that ActiveScaffold is trying to access the
children post_meta_data and use an inflexion "datum".

I don't understand since I haven't written any custom inflection, and
Ruby on Rails has generated the pluralized "datas" itself.

Can someone help me ?

Thanks.


Le 25/01/2011 09:43, vhochstein a �crit :

vhochstein

unread,
Jan 26, 2011, 2:27:00 AM1/26/11
to ActiveScaffold : Ruby on Rails plugin
Hi,

it s quite uncommon to hijack a running thread....

Nevertheless, which version of active_scaffold are you using?

--
Volker

Sergio Cambra .:: entreCables S.L. ::.

unread,
Jan 26, 2011, 3:43:58 AM1/26/11
to actives...@googlegroups.com
On Martes, 25 de Enero de 2011 12:48:55 Yves-Emmanuel Jutard escribió:
> Hello,
>
> I have a data structure like that :
> * Post (post/posts) which "has_many" post_meta_datas
> * PostMetaData (post_meta_data/post_meta_datas) which "belongs_to" post
>
> I write a simple controller for using activescaffold, and when I list my
> posts, I get a nasty error "uninitialized constant Post::PostMetaDatum"
>
> It looks like (I think...) that ActiveScaffold is trying to access the
> children post_meta_data and use an inflexion "datum".
>
> I don't understand since I haven't written any custom inflection, and
> Ruby on Rails has generated the pluralized "datas" itself.
>
> Can someone help me ?

A backtrace with backtrace silencers removed would be useful.

>
> Thanks.

--
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) ser...@entrecables.com

Yves-Emmanuel Jutard

unread,
Jan 26, 2011, 7:57:51 AM1/26/11
to actives...@googlegroups.com
Hello and thanks for the advices,

I found my error and must apologize for suspecting ActiveScaffold.

It happen that I forgot an "s" on my "...data" where I should have
written a pluralized form, then Rails, trying to get the singular form,
used its rule converting plural "a" to singular "um", cf.
http://blog.luckyus.net/2009/02/03/rails-inflection-of-metadata-and-data/

It showed up in ActiveScaffold first, but it was not related.

Thank you again for the answers, and long live ActiveScaffold.

Le 26/01/2011 09:43, Sergio Cambra .:: entreCables S.L. ::. a �crit :
> On Martes, 25 de Enero de 2011 12:48:55 Yves-Emmanuel Jutard escribi�:


>> Hello,
>>
>> I have a data structure like that :
>> * Post (post/posts) which "has_many" post_meta_datas
>> * PostMetaData (post_meta_data/post_meta_datas) which "belongs_to" post
>>
>> I write a simple controller for using activescaffold, and when I list my
>> posts, I get a nasty error "uninitialized constant Post::PostMetaDatum"
>>
>> It looks like (I think...) that ActiveScaffold is trying to access the
>> children post_meta_data and use an inflexion "datum".
>>
>> I don't understand since I haven't written any custom inflection, and
>> Ruby on Rails has generated the pluralized "datas" itself.
>>
>> Can someone help me ?
> A backtrace with backtrace silencers removed would be useful.
>
>> Thanks.
>>

>> Le 25/01/2011 09:43, vhochstein a �crit :

Reply all
Reply to author
Forward
0 new messages