Skip to content

How to change controllers, models, views, assets and locales

Reydel Leon edited this page May 5, 2013 · 8 revisions

Overwriting

Social Stream is a Rails Engine. This means that you can customize every single file in app/. All you have to do is copy the file from Social Stream's gem to you application's app/. Your application's file will take precedence over the original file in Social Stream

Social Stream is distributed as a gem. To find where Social Stream is installed, you can use bundle show social_stream-base, bundle show social_stream-documents, etc.

The same applies to localization messages. Entries in you application's config/locales/* take precedence over Social Stream's.

Decorators and mixins

Note that files copied to your application will not be updated when Social Stream is updated. They will not get new features and bug fixes. The a way to avoid this is using decorators. They are implemented in the rails_engine_decorators gem. All you have to do is:

  • Create a module that adds the functionality:
module MyFunctionality
 ...
end
  • Create a decorator in app/decorators/models/social_stream/base/user_decorator.rb that includes the module using class_eval:
require "MyFunctionality"

User.class_eval do
  include MyFunctionality
end

Here is a link to a sample application, which just extends the User model:

https://github.com/papeldeorigami/ss_model_decorator

Clone this wiki locally