lib/generators/effective/views_generator.rb in effective_developer-0.0.10 vs lib/generators/effective/views_generator.rb in effective_developer-0.1.1
- old
+ new
@@ -15,26 +15,23 @@
argument :actions, type: :array, default: ['crud'], banner: 'action action'
class_option :attributes, type: :array, default: [], desc: 'Included form attributes, otherwise read from model'
def assign_attributes
- @attributes = (invoked_attributes.presence || klass_attributes).map do |attribute|
- Rails::Generators::GeneratedAttribute.parse(attribute)
- end
-
+ @attributes = invoked_attributes.presence || resource_attributes
self.class.send(:attr_reader, :attributes)
end
def invoke_views
say_status :invoke, :views, :white
end
def create_views
(invoked_actions & available_actions).each do |action|
- template "views/#{action}.html.haml", File.join('app/views', namespace_path, (namespace_path.present? ? '' : class_path), plural_name, "#{action}.html.haml")
+ template "views/#{action}.html.haml", resource.view_file(action)
end
- template "views/_resource.html.haml", File.join('app/views', namespace_path, (namespace_path.present? ? '' : class_path), plural_name, "_#{singular_name}.html.haml")
+ template 'views/_resource.html.haml', resource.view_file(resource.name, partial: true)
end
private
def available_actions