Embedded Scaffolds in Rails 2.3.2

100 views
Skip to first unread message

Michelschr

unread,
Mar 17, 2009, 3:30:19 PM3/17/09
to ActiveScaffold : Ruby on Rails plugin
Hello everyone,

The controllers managed with AS are wonderful and it's very nice when
we can embed them within a page of information. Following the AS wiki,
we was able to write in your controller something like:

render :active_scaffold => 'entries', :constraints => { :user_id =>
@user.id }

This mechanism was previously based on render_component which
disappear in Rails 2.3.2.

What should we do now to have the same behavior? What is the best way?

After reading the discussions in this forum and even testing different
solutions without success, it is still unclear for me... (different
render_component plugin branches... render_sibling...?)

I am sure that a lot of people will appreciate a clear explanation
about this topic.

Thanks in advance,



Benjamín Cárdenas Salamandra

unread,
Mar 17, 2009, 6:52:27 PM3/17/09
to actives...@googlegroups.com
Hola,

Is render_component, but to me in jruby not work yet,

Benjamin

Michelschr escribió:

Atastor

unread,
Mar 18, 2009, 4:03:10 AM3/18/09
to ActiveScaffold : Ruby on Rails plugin
Well..for me its a bit obscure, too. But what *does* work (for me :))
is the edge branch of lackac:

script/plugin install --force git://github.com/lackac/render_component.git
-r rails-edge

Regards
Michael

Michelschr

unread,
Mar 18, 2009, 6:53:41 AM3/18/09
to ActiveScaffold : Ruby on Rails plugin
Thanks a lot,

Following your advice I did:

script/plugin install --force git://github.com/lackac/render_component.git
-r rails-edge

And effectively, Rails started correctly.

Then I had to change my call: previously I had:

<%= render :active_scaffold => "Demos", :constraints => {:demo =>
true, :fixed => true}, :label => "Demos" %>

and living that make a lot of garbage... So I change to:

<%= render_component :controller => "Demos", :action => "table" %>

I had to change to the "table" action to remove the layout... And like
that, it begin to work...

But, if I try to pass " :label => "Demos" " it doesn't work: AS keep
the "config.label = "Demos default" " that is set in the controller...

Up to now I didn't test with the constraints...

But we are progressing...

Can anyone help me further...?

(for Benjamin: is this approach also not working with jruby...?)

Tanks in advance for tour answers,

Michel

Michelschr

unread,
Mar 18, 2009, 11:21:35 AM3/18/09
to ActiveScaffold : Ruby on Rails plugin
Next episode... (Passing parameters to Embedded Active Scaffold with
render_component)

Where I had:

<%= render :active_scaffold => "Demos", :label => "Passed" %>

Now, with Rails 2.3.2 and render_component (see the previous
messages), if I want to send a new label to AS, I should (maybe there
are other ways, but this one seems to work...) first create a new
entry in the session like that:

<% session["as:12345"] = {:list => {:label => "Passed"}} %>
<%= render_component :controller => "Demos", :action =>
"table", :params => { :eid => "12345" } %>

For sure, it will be better if "12345" is a unique generated key...

So, it seems that this is a work around...

But it would probably be even better if we had a nice official way to
do that... Maybe the old syntax and AS doing the right job in the
background...?

I still would really appreciate the advice of the core Active Scaffold
specialists...

Thanks in advance,

Michel

Michelschr

unread,
Mar 18, 2009, 11:21:48 AM3/18/09
to ActiveScaffold : Ruby on Rails plugin
Next episode... (Passing parameters to Embedded Active Scaffold with
render_component)

Where I had:

<%= render :active_scaffold => "Demos", :label => "Passed" %>

Now, with Rails 2.3.2 and render_component (see the previous
messages), if I want to send a new label to AS, I should (maybe there
are other ways, but this one seems to work...) first create a new
entry in the session like that:

<% session["as:12345"] = {:list => {:label => "Passed"}} %>
<%= render_component :controller => "Demos", :action =>
"table", :params => { :eid => "12345" } %>

For sure, it will be better if "12345" is a unique generated key...

So, it seems that this is a work around...

But it would probably be even better if we had a nice official way to
do that... Maybe the old syntax and AS doing the right job in the
background...?

I still would really appreciate the advice of the core Active Scaffold
specialists...

Thanks in advance,

Michel

On 18 mar, 11:53, Michelschr <michels...@gmail.com> wrote:

Michelschr

unread,
Mar 18, 2009, 1:08:51 PM3/18/09
to ActiveScaffold : Ruby on Rails plugin
Hoolala...!! (Everything ok... but my way...)

I put that in ApplicationHelper:

def render_as(par)
# ....... in ApplicationHelper
# Usage:
# Where you had : <%= render :active_scaffold =>
"Demos", :constraints => {:demo => true, :fixed => true}, :label =>
"Demos" %>
# Simply put: <%= render_as :active_scaffold =>
"Demos", :constraints => {:demo => true, :fixed => true}, :label =>
"Demos" %>
# Thus in your view, you simply replace render by render_as

# We need a key to transfer to AS and to store something in the
session...
# Every time we call render_as with the same parameters, we can
use the same key, and like that, we don't have every time a new entry
in the session...
uniq = par.to_s

as_controller = par[:active_scaffold]

par.delete(:active_scaffold)

session["as:"+ uniq] = {:list => par}
# implicit: we just render list...

return render_component :controller => as_controller, :action =>
"table", :params => { :eid => uniq }
# thus we need render_component
end

Up to now, it seems to work... with little change in the original view
code.

Expert advice will still be very appreciated...

Hope it helps in the meantime,

Michel

Michelschr

unread,
Mar 18, 2009, 1:09:24 PM3/18/09
to ActiveScaffold : Ruby on Rails plugin
Hoolala...!! (Everything ok... but my way...)

I put that in ApplicationHelper:

def render_as(par)
# ....... in ApplicationHelper
# Usage:
# Where you had : <%= render :active_scaffold =>
"Demos", :constraints => {:demo => true, :fixed => true}, :label =>
"Demos" %>
# Simply put: <%= render_as :active_scaffold =>
"Demos", :constraints => {:demo => true, :fixed => true}, :label =>
"Demos" %>
# Thus in your view, you simply replace render by render_as

# We need a key to transfer to AS and to store something in the
session...
# Every time we call render_as with the same parameters, we can
use the same key, and like that, we don't have every time a new entry
in the session...
uniq = par.to_s

as_controller = par[:active_scaffold]

par.delete(:active_scaffold)

session["as:"+ uniq] = {:list => par}
# implicit: we just render list...

return render_component :controller => as_controller, :action =>
"table", :params => { :eid => uniq }
# thus we need render_component
end

Up to now, it seems to work... with little change in the original view
code.

Expert advice will still be very appreciated...

Hope it helps in the meantime,

Michel


On 18 mar, 16:21, Michelschr <michels...@gmail.com> wrote:

Atastor

unread,
Mar 22, 2009, 5:42:42 PM3/22/09
to ActiveScaffold : Ruby on Rails plugin
Well...your suggestion works fine...but I encounter the following
problem. Each
time I visit the page with the embedded scaffold on it the sessions-
table is overloaded
with data.This quite frequently leads to db-errors due to the size of
the entry. It
seems that the whole of the melduns-table is loaded into the session.
Any idea what is
causing this? Im using the following conditions in the render:

<%= render_as :active_scaffold => 'melduns',
:conditions => ['meldst_id IN (:mldsts) AND prgpkt_id IN
(:prgpkts)', {:mldsts => @meldsts, :prgpkts => @prgpkts}]
%>

Michael

Ps and Btw: the same behaviour shows, even when I dont use your
"render_as".

Michelschr

unread,
Mar 23, 2009, 6:29:01 AM3/23/09
to ActiveScaffold : Ruby on Rails plugin
This seems strange... And I have no idea why it happens...

What I know is that AS write entries in the sessions to pass
parameters when it make a nested call... Thus, I just simulate this
behavior to stay as close as possible to AS...

I founded other strange (and probably wrong...) behaviors in AS for
Rails 2.3.2...

Atastor

unread,
Mar 25, 2009, 6:15:26 AM3/25/09
to ActiveScaffold : Ruby on Rails plugin
There is a new version of render_component floating around, author
Adam Walker, branching off lackac; check the network-graph for
render_component (its "-r rails-edge" again :) ). Its a minor change
and it does not influence my use of embedded scaffolds, but you might
want to have a look at it.

Regards
Michael

Atastor

unread,
Mar 25, 2009, 9:04:12 AM3/25/09
to ActiveScaffold : Ruby on Rails plugin
Btw: taking out the :conditions part remedies the session-size
problem. With it the marshalled session in the sessions table of the
database has a size of more than 200k!!! Sqlite doesnt budge, but its
definitively too much for poor little mysql.

Puzzled
Michael

Meech

unread,
Mar 30, 2009, 9:55:54 AM3/30/09
to ActiveScaffold : Ruby on Rails plugin
Also, I noticed that the render_component plugin breaks flash[].

I hope the AS team is working to remove the rendor_component stuff.

Dovadi

unread,
Mar 31, 2009, 8:21:37 AM3/31/09
to ActiveScaffold : Ruby on Rails plugin
I used the fork of lackac (script/plugin install git://github.com/lackac/render_component.git
-r RAILS-EDGE). This worked fine, except for the flash problem. I
fixed this by disabling the
alias_method_chain :assign_shortcuts, :render_component, line 15 of
components.rb (See also http://github.com/lackac/render_component/commit/e851c6427d25784fd450529a446f43def159d4df).

I wrote lackac about this problem and he would look into it.

Best, Frank

slava

unread,
Apr 9, 2009, 5:14:01 PM4/9/09
to ActiveScaffold : Ruby on Rails plugin
Hi all,
I am having the same problem - undefined method `render_component'

but I am not using embedded active scaffold, just a standard one with
rails 2.3.2

when I click on a link in a column of active scaffold I get this
error.

what do I do?

Michelschr

unread,
Apr 10, 2009, 7:39:13 AM4/10/09
to ActiveScaffold : Ruby on Rails plugin
It's already a long time ago that I started this threat...

I tried to make ad hoc propositions... but I'm not a core expert of
AS...

March 18 I wrote: "I still would really appreciate the advice of the
core Active Scaffold
specialists... "

... and we are still on the same point ... We received no orientation
at all ...

What conclusions shroud we take...?

Kenny Ortmann

unread,
Apr 10, 2009, 9:59:59 AM4/10/09
to actives...@googlegroups.com
Until AS removes the calls to render component you need to install the version of render component found here

git://github.com/lackac/render_component.git

ramblezeus

unread,
Apr 29, 2009, 11:11:40 PM4/29/09
to ActiveScaffold : Ruby on Rails plugin
After I install the render_component plugin, rails is not starting
I tried with render component from both git://github.com/rails/render_component.git
and git://github.com/lackac/render_component.git

=> Booting WEBrick
=> Rails 2.3.2 application starting on http://0.0.0.0:14118
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
core_ext/module/aliasing.rb:33:in `alias_method': undefined method
`set_session_options' for class `ActionController::Base' (NameError)
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/core_ext/module/aliasing.rb:33:in `alias_method_chain'
from /home/tarun/source/wn-ror/vendor/plugins/render_component/
lib/components.rb:13:in `included'
from /home/tarun/source/wn-ror/vendor/plugins/render_component/
lib/components.rb:3:in `class_eval'
from /home/tarun/source/wn-ror/vendor/plugins/render_component/
lib/components.rb:3:in `included'
from /home/tarun/source/wn-ror/vendor/plugins/render_component/
init.rb:2:in `include'
from /home/tarun/source/wn-ror/vendor/plugins/render_component/
init.rb:2:in `send'
from /home/tarun/source/wn-ror/vendor/plugins/render_component/
init.rb:2:in `evaluate_init_rb'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails/
plugin.rb:146:in `evaluate_init_rb'
... 16 levels...
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/
server.rb:84
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
31:in `gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
31:in `require'
from script/server:3

On Apr 10, 9:59 am, Kenny Ortmann <kenny.ortm...@gmail.com> wrote:
> Until AS removes the calls to render component you need to install the
> version of render component found here
>
> git://github.com/lackac/render_component.git
>

Atastor

unread,
Apr 30, 2009, 7:17:26 AM4/30/09
to ActiveScaffold : Ruby on Rails plugin
Haven't checked the status of the different branches lately, so my
statement might be falsified by reality already. But one question: did
you use the additional "-r rails-edge" option on the "plugin
install"?

Regards Michael

On Apr 30, 5:11 am, ramblezeus <ezta...@gmail.com> wrote:
> After I install the render_component plugin, rails is not starting
> I tried with render component from both git://github.com/rails/render_component.git
> and git://github.com/lackac/render_component.git
>
> => Booting WEBrick
> => Rails 2.3.2 application starting onhttp://0.0.0.0:14118/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/l...

Mr. Ronald

unread,
Jun 5, 2009, 3:08:39 AM6/5/09
to ActiveScaffold : Ruby on Rails plugin
Thanks, Michael, this helped me a lot:
script/plugin install -f -r rails-edge git://github.com/lackac/render_component.git
Reply all
Reply to author
Forward
0 new messages