tog / tog watch
public
Description: Base gem that bootstrap tog platform configuration in a Rails app
Home | Edit | New

Developer FAQ

  1. Add comments to your models
  2. Add your own observer
  3. Create ‘report abuse’ links
  4. Include my own javascripts in template header
  5. Run tests for a given plugin
  6. Fulfill dependencies to run test


h2. Add comments to your models

Tog uses acts_as_commentable, so, first make your model commentable:

class Conversatio::Post < ActiveRecord::Base
  acts_as_commentable
  ...

And now make the following include in your view (substitute @post for your commentable instance):

  <%= render :partial => "shared/comments", :locals => { :commentable => @post } %>

And, for the notification email, your model needs to tell who is it’s owner, so have to repond to “owner” (as a method or a relationship), returning an instance of User

   belongs_to :user
   ...
   def owner
        user
   end
   ...

Done. You have comments with permalinks, for registered and anonymous users, with antispam, denounced as abuse and much more.


h2. Add your own observer

Create your observer (in this case: MailFoldersObserver) and use this on initialization:

Tog::Plugins.observers << :mail_folders_observer


h2. Create ‘report abuse’ links

tog_core comes with a helper method for easy links creation:

report_abuse_link(object, text, options)

Example:

<%= report_abuse_link(@comment, 'Report abuse', :class => 'abuse_link') -%>


h2. Include my own javascripts in template header

If one of your plugins uses an specific javascript, you can add it automatically to the template header using the following helper method in your view:

<% include_javascript "vault/admin" %>

Add the following in your template header to include all this files:

<%= inject_js %>

The same is valid for CSS using

   <% include_stylesheet "vault/styles" %>
   ...
   <%= inject_css %>


h2. Run tests for a given plugin

rake tog:plugins:test PLUGIN=plugin_name

For example:

rake tog:plugins:test PLUGIN=tog_conclave


h2. Fulfill dependencies to run test

You have to fulfill these three dependecies:

thoughtbot-factory_girl
thoughtbot-shoulda
mocha
Last edited by IamPersistent, Mon Mar 09 19:47:16 -0700 2009
Home | Edit | New
Versions: