Skip to content

Commit

Permalink
Update of helpers and associations to get templates running
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenvandijk committed Feb 21, 2009
1 parent 8ccedf5 commit 045bff4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions templates/make_resourceful_ideal/fixtures.yml.erb
@@ -1,13 +1,13 @@
<% 1.upto(number_of_entities) do |id| -%>
<%= "#{file_name}_#{id}" %>:
<% model.attributes_for(:mass_assignment).each do |attribute| -%>
<%= "#{model.singular_name}_#{id}" %>:
<% model.attributes_for(:form).each do |attribute| -%>
<%= attribute.name %>: <%= attribute.default %>
<% end -%>
<% (model.collection_names).each do |child| -%>
<% model.collection_names.each do |child| -%>
<%= "#{child}: " + (id..number_of_entities).map{|x| "#{child.singularize}_#{x}" }.join(", ")%>
<% end -%>
<% model.association_names(:belongs_to).each do |parent| -%>
<%= "#{parent}: #{parent}_#{id}" %>
<% model.belongs_to_associations.each do |parent| -%>
<%= "#{parent.name}: #{parent.name}_#{id}" %>
<% end -%>
<% end -%>
14 changes: 7 additions & 7 deletions templates/make_resourceful_ideal/model.rb.erb
@@ -1,9 +1,9 @@
<%= model.define_model %>
## ASSOCIATIONS
<%#= model.define_associations %>
<%= model.add_associations %>

## RESTRICTIONS
<%# model.define_accessible_attributes %>
<%= model.define_accessible_attributes %>

## CONSTANTS

Expand All @@ -16,8 +16,8 @@
## NAMED_SCOPES

## PRESENCE VALIDATIONS
<%#= model.presence_validations %>

<%= model.presence_validations(16) %>
## ASSOCIATED VALIDATIONS
<%#= model.association_validations %>

Expand All @@ -41,9 +41,9 @@
def self.scope_by_params(params = {}, options = {})
## TODO replace this with a proper search generic find code here
scope = scoped({})
<%# model.attribute_symbols.each do |field| -%>
scope = scope.scoped :conditions => { <%#= field %> => params[<%#= field %>] } if params[<%#= field %>]
<%# end -%>
<% model.attributes.each do |field| -%>
scope = scope.scoped :conditions => { :<%= field.name %> => params[:<%= field.name %>] } if params[:<%= field.name %>]
<% end -%>
scope

end
Expand Down

0 comments on commit 045bff4

Please sign in to comment.