Why does no one like render_component?

Maybe I’m missing the point?

Lets take for example albums of pictures. If I have a scaffold for
each, and I’m showing an album, what if I want to list all of the
pictures that are in the album?

Surely, I’d want to call the List action in the picture controller.
render_component would do this perfectly. But we’re told not to use
render_component. So instead, I’ll have to put picture list as a
partial… that means I’ll have to do the sql find for the @pictures in
the Album controller…?

-Ben L.

Ben L. [email protected] writes:

Maybe I’m missing the point?

its not people don’t like them, but just don’t use them everywhere
because
they are slow. Using render_component is like making another request.
using partials is better as they are faster.

Lets take for example albums of pictures. If I have a scaffold for
each, and I’m showing an album, what if I want to list all of the
pictures that are in the album?

Surely, I’d want to call the List action in the picture controller.
render_component would do this perfectly. But we’re told not to use
render_component. So instead, I’ll have to put picture list as a
partial… that means I’ll have to do the sql find for the @pictures in
the Album controller…?

If you think that your application logic will be cleaner, and you can
reuse
them at multiple places, even from outside the application, then use a
render_component.

Cheers,

Surendra S.
http://ssinghi.kreeti.com, http://www.kreeti.com
Read my blog at: http://cuttingtheredtape.blogspot.com/
,----
| Great wits are sure to madness near allied,
| And thin partitions do their bounds divide.
|
| (John Dryden, Absalom and Achitophel, 1681)
`----

Hi,

I have a acts_as_tree model but I'm not able to create the first 

item without a parent.

With this model:

class Node < ActiveRecord::Base
	acts_as_tree
end

I run:
n = Node.new
n.name = ‘my node’
n.save

I get this error

ActiveRecord::RecordNotFound: Couldn't find Subsystem without an ID
    from 

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/ac…

Please, my head is burning… I thought it was a database problem with
fks, I removed them but it persists.

Somebody help me!

TIA
Romeu Fonseca


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.10.10/419 - Release Date:
15/8/2006

Surely, I’d want to call the List action in the picture controller.
render_component would do this perfectly. But we’re told not to use
render_component. So instead, I’ll have to put picture list as a
partial… that means I’ll have to do the sql find for the @pictures in
the Album controller…?

-Ben L.

Ben:

Actually, if an Album has_many photos, then it’s a matter of doing this
in
your controller:

def list
@album = Album.find(params[:id], :include=>[:photos]
@photos = @album.photos
end

This gets you the album AND its photos in one database call.

Then in your view, you render the partial

<%=render :partial =>"/shared/photos" %>

Partials are definitely the way to go for most of this stuff. I had
component rendering going on in one of my earlier projects and I started
noticing some pretty nasty performance problems. I refactored several of
those into partials, and others I left in, but I made sure to use
fragment
and action caching wherever I could to improve performance.

Somebody please!!!

-----Mensagem original-----
De: [email protected]
[mailto:[email protected]] Em nome de Romeu Henrique
Capparelli F.
Enviada em: quarta-feira, 16 de agosto de 2006 17:36
Para: [email protected]
Assunto: [Rails] acts_as_tree: creating the first element

Hi,

I have a acts_as_tree model but I'm not able to create the first 

item without a parent.

With this model:

class Node < ActiveRecord::Base
	acts_as_tree
end

I run:
n = Node.new
n.name = ‘my node’
n.save

I get this error

ActiveRecord::RecordNotFound: Couldn't find Subsystem without an ID
    from 

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/ac…

Please, my head is burning… I thought it was a database problem with
fks, I removed them but it persists.

Somebody help me!

TIA
Romeu Fonseca


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.10.10/419 - Release Date:
15/8/2006


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.10.10/419 - Release Date:
15/8/2006


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.1/421 - Release Date:
16/8/2006

On Aug 16, 2006, at 3:35 PM, Romeu Henrique Capparelli F. wrote:

ActiveRecord::RecordNotFound: Couldn’t find Subsystem without an ID
from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/
ac…

this looks like a db schema error – check that you have appropriate
primary and foreign keys, and if that fails, post your schema?

-faisal