On Oct 16, 10:16 am, Alfredo Garcia lopez <rails-mailing-l...@andreas-
s.net> wrote:
> Needings are:
> *add,overwrite models,controllers,helpers methods
> *add,overwrite views with possibility to render the overwritten view
> from the new view.This is the most complex part because several modules
> could overwrite the same view.
> *for css,js and images I´m not sure if i would use generators or perhaps
> the posibility to define several public directories with preference
> order.
It sounds like these are some ambitious goals! I''d recommend starting
with the simplest components and extracting more and more as necessary
to keep it manageable. For the simple functionality extracting it into
Modules in /lib and including them in your Models and Controllers can
help to keep things DRY and cohesive.
Example:
class Commerce::CommerceController < ApplicationController
include CustomerLoader
layout ''commerce''
...
end
module CustomerLoader
# Makes cart and customer available as ActionView helper method.
def self.included(base)
base.send :helper_method, :current_customer, :cart if
base.respond_to? :helper_method
end
protected
def current_customer
...
end
def cart
...
end
end
After you get some Modules separated it may make sense to group those
together and bundle it as a gem. I don''t have much experience with
that but it is an excellent tool for code sharing and reuse,
especially with Rails 2.1 config.gem shizzy.
Additionally you can use inheritance to isolate the places that need
to change. Be sure that you''re dealing with is-a relationships though.
Example:
module Commerce
class ProductsController < CommerceController
...
end
end
For your CSS and .js I think that having different layouts that
include the correct files would be the best way. You could even choose
the layout dynamically.
For some more tips look around the code of some of your favorite
plugins and see how they''ve handled these issues. The ways
I''ve
suggested are just a few and won''t get you all the way there, but I
hope that they''ve been a good starting point and will open up the
discussion to some more techniques.
Hope to have helped,
Dimo
http://strd6.com/blog
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---