Forum: Ruby on Rails components vs engines

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eea3feaacbe44706164289d068d94828?d=identicon&s=25 petermichaux (Guest)
on 2005-11-25 02:55
(Received via mailing list)
Hi,

What are the main differences between components vs. engines? It looks
like
the are both vertical slices of an application.

Thanks,
Peter
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 james.adam (Guest)
on 2005-11-25 09:30
(Received via mailing list)
http://rails-engines.rubyforge.org/wiki/wiki.pl?Co...

Components are essentially like partials with their own controller
logic - meant to be rendered within other views. Engines can have
full-blown views, controllers, helpers, possibly models, libraries...
all or only as much of that list as you need.

- james
280b41a88665fd8c699e83a9a25ef949?d=identicon&s=25 steve (Guest)
on 2005-11-25 16:30
(Received via mailing list)
Peter Michaux wrote:
>
> What are the main differences between components vs. engines? It looks
> like the are both vertical slices of an application.

Components are less feature blessed, but fit very nicely into the
framework.  The Engine is opposite of that.

--Steve
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 james.adam (Guest)
on 2005-11-25 17:23
(Received via mailing list)
On 11/25/05, Stephen Waits <steve@waits.net> wrote:
> Components are less feature blessed, but fit very nicely into the
> framework.  The Engine is opposite of that.

*sigh*
Eea3feaacbe44706164289d068d94828?d=identicon&s=25 petermichaux (Guest)
on 2005-11-26 05:13
(Received via mailing list)
Hi,

Reading in the Rails book[1] and looking at the ActiveRBAC component[2]
it
seems that components have a nasty directory structure. I don't see any
hierarchical logic to the following structure. Lumping models and
controllers and then somehow views are contained in this lump.

components/
   component/
      role.rb
      role_controller.rb
      role/
         view.rhtml

Integrated in a Rails apps these files would be so nicely divided up in
the
app directory

app/
  models/
     role.rb
  controllers/
     role_controller.rb
  view/
     view.rhtml

Does the seemingly messy directory structure of the component indicate
that
the components facility is asked to do too much in this case? Could the
component's files structure be improved or does convention make that
difficult? Would an engine be a better way to go?

Thanks,
Peter

[1] Agile Web Development with Rails (p376)
[2] https://rbaconrails.turingstudio.com/trac/wiki
0bcc972918891ef358b0b3dfb4e7f18b?d=identicon&s=25 hammed (Guest)
on 2005-11-26 09:27
(Received via mailing list)
>Reading in the Rails book[1] and looking at the ActiveRBAC
component[2] it seems that components have a nasty directory
structure. I don't see any hierarchical logic to the following
structure.

I think you've nailed it - I've been avoiding components for the same
reason. The parts of my app that I'd like to reuse in other projects,
I'm planning on building as engines.

Hammed
Eb234d1ee9f1dcd334657d7c5c1b1c4d?d=identicon&s=25 Jamie Macey (jamie)
on 2005-11-30 02:16
(Received via mailing list)
Back in the days of 0.9, we were looking at cleaning up components to
match the app structure.  So you'd be able to do things like:

components/
  component/
    controllers/
      role_controller.rb
    models/
      role.rb
    views/
      role/
        view.rhtml

If I recall, the changes included a few extra default path patterns, a
2-line change in rendering so that one could override component layouts
from within the regular app/ tree, and a minor fix to
uses_component_template_root.

The sticking point was that each component controller would need to
include the line 'uses_component_template_root' which was the one
sticking point I never figured out how to do.  If that could be figured
out, one could use svn externals to another project's app/ directory,
and have a local copy with no fuss.

Alas, I never had the time to finish things, and in the rapid
development going forward I gave up on them.

>From what I understand though, the reason components is so crappy is
because someone half-thought through the idea, and abandoned it.
Nobody's backed it out of the framework, and nobody's stepped up to do
it right either.

- Jamie
8a456610e31c8feadc4cef71d9347cbd?d=identicon&s=25 craig (Guest)
on 2005-11-30 03:28
(Received via mailing list)
Interesting points there Jamie. I've had a bit of a stab at something
similar, but just like you, I haven't persisted with it due to the need
to actually press on with development. I'd really like components to get
to a point where (or be replaced by) they are identical from rails apps
themselves. This self-similar structure would allow for better re-use of
regularly repeated parts of the application which could be tested, and
possibly also used, as stand alone apps. And before anyone says it, yes
engines are great, but no they don't do the same thing. Engines give a
site an area of functionality (a vertical slice if you will). Components
give your site a drag and drop 'think' which contains complex
functionality but can be 'instanced' many times on the site.

eg:

Engine: I want my site to have blogging functionality, accessed via the
blog controller.
Component: I want to be able to add editable blogs to pages on my site,
accessed via whatever controller manages those pages.

regards,

Craig
This topic is locked and can not be replied to.