diff --git a/lib/Rails/Panel/views/admin/create_files.php b/lib/Rails/Panel/views/admin/create_files.php
index 0af096a..3688db8 100755
--- a/lib/Rails/Panel/views/admin/create_files.php
+++ b/lib/Rails/Panel/views/admin/create_files.php
@@ -28,6 +28,11 @@
+
-
\ No newline at end of file
+
diff --git a/lib/Rails/Toolbox/FileGenerators/ControllerGenerator.php b/lib/Rails/Toolbox/FileGenerators/ControllerGenerator.php
index 248b717..9462229 100755
--- a/lib/Rails/Toolbox/FileGenerators/ControllerGenerator.php
+++ b/lib/Rails/Toolbox/FileGenerators/ControllerGenerator.php
@@ -33,17 +33,6 @@ class ControllerGenerator extends AbstractGenerator
$filePath = $baseDir . DIRECTORY_SEPARATOR . $fileName;
}
- if (is_file($filePath)) {
- $message = sprintf("File already exists (pass 'f' to overwrite): %s", $filePath);
- if ($console) {
- $console->terminate($message);
- } else {
- throw new Exception\FileExistsException(
- $message
- );
- }
- }
-
$defaultOptions = [
'parent' => ''
];
@@ -72,14 +61,34 @@ class ControllerGenerator extends AbstractGenerator
$parent,
], $template);
- if (!file_put_contents($filePath, $contents)) {
- $msg = "Couldn't create file";
+ if (!is_file($filePath)) {
+ if (!file_put_contents($filePath, $contents)) {
+ $msg = "Couldn't create file";
+ if ($console) {
+ $console->terminate($msg);
+ } else {
+ throw new Exception\FileNotCreatedException(
+ $msg
+ );
+ }
+ }
+ } else {
if ($console) {
- $console->terminate($msg);
- } else {
- throw new Exception\FileNotCreatedException(
- $msg
- );
+ $console->write("File already exists: " . $filePath);
+ }
+ }
+
+ # Create view folder
+ $viewsPath = Rails::config()->paths->views;
+ $viewFolder = $viewsPath . '/' . Rails::services()->get('inflector')->underscore($name);
+ if (!is_dir($viewFolder)) {
+ mkdir($viewFolder);
+ if ($console) {
+ $console->write("Created directory: " . $viewFolder);
+ }
+ } else {
+ if ($console) {
+ $console->write("Directory already exists: " . $viewFolder);
}
}
@@ -96,6 +105,7 @@ class ControllerGenerator extends AbstractGenerator
class %className% extends %parent%
{
-}';
+}
+';
}
}
\ No newline at end of file
diff --git a/lib/Rails/Toolbox/FileGenerators/ModelGenerator.php b/lib/Rails/Toolbox/FileGenerators/ModelGenerator.php
index 292f3d6..52a716b 100755
--- a/lib/Rails/Toolbox/FileGenerators/ModelGenerator.php
+++ b/lib/Rails/Toolbox/FileGenerators/ModelGenerator.php
@@ -34,13 +34,11 @@ class ModelGenerator extends AbstractGenerator
}
if (is_file($filePath)) {
- $message = sprintf("File already exists (pass 'f' to overwrite): %s", $filePath);
+ $message = sprintf("File already exists: %s", $filePath);
if ($console) {
$console->terminate($message);
} else {
- throw new Exception\FileExistsException(
- $message
- );
+ return false;
}
}