lib/generators/adminpanel/resource/resource_generator.rb in adminpanel-1.2.8 vs lib/generators/adminpanel/resource/resource_generator.rb in adminpanel-1.2.9
- old
+ new
@@ -32,10 +32,14 @@
end
end
false
end
+ def gallery_name
+ "#{lower_name}file"
+ end
+
def lower_name
name.singularize.downcase
end
def capitalized_resource
@@ -81,11 +85,11 @@
fields.each do |attribute|
assign_attributes_variables(attribute)
if @attr_type == "images"
- attr_string = attr_string + ":#{@attr_field.pluralize.downcase}_attributes, "
+ attr_string = attr_string + ":#{gallery_name.pluralize}_attributes, "
elsif @attr_type == "belongs_to"
attr_string = "#{attr_string}:#{belongs_to_field(@attr_field)}, "
elsif @attr_type == "has_many" || @attr_type == "has_many_through"
if @attr_field.split(",").second == nil
attr_string = "#{attr_string}:#{has_many_field(@attr_field)}, "
@@ -140,11 +144,11 @@
"#{label_type}," +
"#{placeholder_type}}\n\t\t\t},"
end
def file_field_hash
- "#{starting_hash(@attr_field.downcase.pluralize)} => {#{form_type('adminpanel_file_field')}," +
+ "#{starting_hash(gallery_name.pluralize)} => {#{form_type('adminpanel_file_field')}," +
"#{label_type}," +
"#{placeholder_type}}\n\t\t\t},"
end
def belongs_to_attribute_hash(name)
@@ -244,14 +248,14 @@
end
end
def image_association
generate_gallery
- return "\n\t\tmount_images :#{@attr_field.pluralize.downcase}\n"
+ return "\n\t\tmount_images :#{gallery_name.pluralize}\n"
end
def generate_gallery
- Rails::Generators.invoke("adminpanel:gallery", lower_name)
+ generate "adminpanel:gallery", lower_name
end
end
end
end