Skip to content

Instantly share code, notes, and snippets.

@anithri
Created February 1, 2013 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anithri/4694736 to your computer and use it in GitHub Desktop.
Save anithri/4694736 to your computer and use it in GitHub Desktop.
active_record model generator template Inserted comments to help keep models organized
<% module_namespacing do -%>
class <%= class_name %> < <%= parent_class_name.classify %>
#extends
#includes
#security
<% if !accessible_attributes.empty? -%>
attr_accessible <%= accessible_attributes.map {|a| ":#{a.name}" }.sort.join(', ') %>
<% else -%>
# attr_accessible :title, :body
<% end -%>
#relationships
<% attributes.select {|attr| attr.reference? }.each do |attribute| -%>
belongs_to :<%= attribute.name %>
<% end -%>
# callbacks
# scopes
# additional config
# class methods
# public instance methods
# protected instance methods
protected
# private instance methods
private
end
<% end -%>
@anithri
Copy link
Author

anithri commented Feb 1, 2013

goes in lib/templates/active_record/model

@anithri
Copy link
Author

anithri commented Feb 1, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment