lib/generators/effective/helpers.rb in effective_developer-0.1.1 vs lib/generators/effective/helpers.rb in effective_developer-0.2

- old
+ new

@@ -10,10 +10,14 @@ def crud_actions %w(index new create show edit update destroy) end + def non_crud_actions + invoked_actions - crud_actions + end + # --actions crud another # --actions crud-show another def invoked_actions actions = (respond_to?(:actions) ? self.actions : options.actions) actions = Array(actions).flat_map { |arg| arg.gsub('[', '').gsub(']', '').split(',') } @@ -48,13 +52,13 @@ def resource_attributes klass_attributes = resource.klass_attributes if klass_attributes.blank? - pending = ActiveRecord::Migrator.new(:up, ActiveRecord::Migrator.migrations(ActiveRecord::Migrator.migrations_paths)).pending_migrations.present? - - migrate = ask("Unable to read the attributes of #{resource.klass}. There are pending migrations. Run db:migrate now? [y/n]") - system('bundle exec rake db:migrate') if migrate.to_s.include?('y') + if ActiveRecord::Migrator.new(:up, ActiveRecord::Migrator.migrations(ActiveRecord::Migrator.migrations_paths)).pending_migrations.present? + migrate = ask("Unable to read the attributes of #{resource.klass || resource.name}. There are pending migrations. Run db:migrate now? [y/n]") + system('bundle exec rake db:migrate') if migrate.to_s.include?('y') + end klass_attributes = resource.klass_attributes end klass_attributes.presence || resource.written_attributes