Skip to content

Commit

Permalink
singular/plural fixes. added seed for config
Browse files Browse the repository at this point in the history
  • Loading branch information
mkristian committed Jan 29, 2012
1 parent c8041a1 commit f16f662
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
4 changes: 4 additions & 0 deletions lib/generators/ixtlan/configuration_base.rb
Expand Up @@ -32,6 +32,10 @@ def create

generate generator_name, *args
end

def create_seed
template 'seed.rb', File.join('db', 'seed.rb')
end
end
end
end
15 changes: 15 additions & 0 deletions lib/generators/ixtlan/templates/seed.rb
@@ -0,0 +1,15 @@

c = Configuration.new
<% if options[:modified_by] -%>
c.modified_by_id = 0
<% end -%>
<% if defined? Ixtlan::Errors -%>
c.errors_keep_dumps = 30
<% end -%>
<% if defined? Ixtlan::Sessions -%>
c.idle_session_timeout = 15
<% end -%>
<% if defined? Ixtlan::Audit -%>
c.audits_keep_logs = 90
<% end -%>
c.save
9 changes: 6 additions & 3 deletions lib/generators/rails/active_record/model/model.rb
Expand Up @@ -3,7 +3,7 @@ class <%= class_name %> < <%= parent_class_name.classify %>
belongs_to :<%= attribute.name %>
<% end -%>
<% attributes.select {|attr| [:has_one, :has_many].include?(attr.type) }.each do |attribute| -%>
<%= attribute.type %> :<%= attribute.name %>
<%= attribute.type %> :<%= attribute.name.singularize %>
<% end -%>
<% if options[:modified_by] -%>
belongs_to :modified_by, :class_name => "User"
Expand All @@ -19,8 +19,11 @@ def self.instance
def self.options
{
<% except = []
except = [:created_at, :updated_at] if options[:timestamps]
except << :modified_by_id if options[:modified_by] -%>
if options[:timestamps]
except = [:created_at]
except << :updated_at unless options[:optimistic]
end
except << :modified_by_id if options[:modified_by] -%>
:except => <%= except.inspect %>
}
end
Expand Down
Expand Up @@ -10,7 +10,7 @@ def cleanup_params
model.delete :id
<% if options[:timestamps] -%>
model.delete :created_at
<% if options[:optimistic] -%>params[:updated_at] = <% end -%>model.delete :updated_at
<% if options[:optimistic] -%>params[:updated_at] ||= <% end -%>model.delete :updated_at
<% if options[:optimistic] -%>
end

Expand Down
Expand Up @@ -9,7 +9,7 @@ def cleanup_params
model = params[:<%= singular_table_name %>] || []
<% if options[:timestamps] -%>
model.delete :created_at
<% if options[:optimistic] -%>params[:updated_at] = <% end -%>model.delete :updated_at
<% if options[:optimistic] -%>params[:updated_at] ||= <% end -%>model.delete :updated_at
<% if options[:optimistic] -%>
end

Expand Down

0 comments on commit f16f662

Please sign in to comment.