Skip to content

papeldeorigami/ss_model_decorator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using decorators to extend Social Stream

This is a sample application built with rails generate integrated with the social_stream engine.

The intention is to exercise the instructions for extending models shown at the social_stream wiki:

github.com/ging/social_stream/wiki/How-to-change-controllers%2C-models%2C-views%2C-assets-and-locales

Some of the code has being inspired by the ViSH source code:

github.com/ging/vish

In this sample we focus on adding new accessible attributes as well as implementing the required migrations and rspec test cases.

These are the main steps taken:

  • define the specs

    ‘spec/spec_helper.rb`

    ‘spec/factories/user.rb`

    ‘spec/models/user_spec.`

  • define a module which extends attributes

    `lib/sample_features.rb`
    
  • define the decorator, including the new module:

    `app/decorators/social_stream/base/user_decorator.rb`
    (notice the dynamic attr_acessible change)
    
  • define the migration:

    `rails generate migration AddSampleAttributeToUsers sample_attribute:string`
    

Execute:

‘rake db:migrate`

‘rake db:test:prepare`

‘rspec`

About

Sample decorator for a Social Stream model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published