https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292017-11-28T03:55:28ZRedmineRedmine - Patch #27659: redmine_plugin_model_generator improvements(fixes and timestamps)https://www.redmine.org/issues/27659?journal_id=823182017-11-28T03:55:28ZToshi MARUYAMA
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/11024">Defect #11024</a>: redmine_plugin_model generator does not create the migration</i> added</li></ul> Redmine - Patch #27659: redmine_plugin_model_generator improvements(fixes and timestamps)https://www.redmine.org/issues/27659?journal_id=823222017-11-28T04:02:23ZToshi MARUYAMA
<ul></ul><p>Javier Menéndez Rizo wrote:</p>
<blockquote>
Problems fixed:
<ul>
<li>parent option not working</li>
<li>migration option not working</li>
</ul>
</blockquote>
<p>Please explain more details.<br />AFAIK Redmine plugin is based old Rails engines, but current Redmine does not implement full feature of Rails engines.</p> Redmine - Patch #27659: redmine_plugin_model_generator improvements(fixes and timestamps)https://www.redmine.org/issues/27659?journal_id=823302017-11-28T13:53:50ZJavier Menéndez Rizo
<ul></ul>Problems:
<ul>
<li>parent option: before the patch the parent option do nothing because in the model.rb template is not defined</li>
</ul>
<p><strong>Before patch model.rb template only inherits from ActiveRecord::Base</strong></p>
<pre>
class <%= @model_class %> < ActiveRecord::Base
</pre>
<p><strong>After patch model.rb template uses the method parent_class_name to calculate the parent and put it on the template</strong></p>
<pre>
class <%= @model_class %> < <%= parent_class_name.classify %>
</pre>
<ul>
<li>migration option: before the patch the generator alway generates the migration file, even if you pass --no-migration</li>
</ul>
<p><strong>After patch redmine_plugin_model_generator.rb i put a guard clause for generate the migration or not</strong></p>
<pre>
return unless options[:migration]
migration_filename = "%.14d_#{@migration_filename}.rb" % migration_number
template "migration.rb", "#{plugin_path}/db/migrate/#{migration_filename}"
</pre> Redmine - Patch #27659: redmine_plugin_model_generator improvements(fixes and timestamps)https://www.redmine.org/issues/27659?journal_id=823312017-11-28T13:58:19ZJavier Menéndez Rizo
<ul></ul><p>New feature:</p>
<p>Timestamps in the name of the generated migration file, right now redmine plugins generates the migrations in this form:<br /><pre>
001_create_polls.rb
</pre></p>
<p><strong>After patch</strong></p>
<pre>
20171127212003_create_polls.rb
</pre> Redmine - Patch #27659: redmine_plugin_model_generator improvements(fixes and timestamps)https://www.redmine.org/issues/27659?journal_id=827862017-12-27T17:28:29ZToshi MARUYAMA
<ul></ul><p>OK, I see.</p>
<p>On trunk <a class="changeset" title="replace plugin generator USAGE "script/rails" which are removed by r16868" href="https://www.redmine.org/projects/redmine/repository/svn/revisions/17132">r17132</a>:</p>
<pre>
$ rails generate redmine_plugin_model --help
Usage:
rails generate redmine_plugin_model NAME MODEL [field[:type][:index] field[:type][:index]] [options]
Options:
[--skip-namespace], [--no-skip-namespace] # Skip namespace (affects only isolated applications)
[--migration], [--no-migration] # Indicates when to generate migration
[--timestamps], [--no-timestamps] # Indicates when to generate timestamps
[--parent=PARENT] # The parent class for the generated model
[--indexes], [--no-indexes] # Add indexes for references and belongs_to columns
# Default: true
Runtime options:
-f, [--force] # Overwrite files that already exist
-p, [--pretend], [--no-pretend] # Run but do not make any changes
-q, [--quiet], [--no-quiet] # Suppress status output
-s, [--skip], [--no-skip] # Skip files that already exist
Description:
Generates a plugin model.
Examples:
bundle exec rails generate redmine_plugin_model meetings pool
</pre> Redmine - Patch #27659: redmine_plugin_model_generator improvements(fixes and timestamps)https://www.redmine.org/issues/27659?journal_id=833282018-01-25T16:21:56ZToshi MARUYAMA
<ul><li><strong>Target version</strong> set to <i>4.1.0</i></li></ul> Redmine - Patch #27659: redmine_plugin_model_generator improvements(fixes and timestamps)https://www.redmine.org/issues/27659?journal_id=924992019-06-20T14:17:15ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Category</strong> set to <i>Plugin API</i></li><li><strong>Status</strong> changed from <i>New</i> to <i>Closed</i></li><li><strong>Assignee</strong> set to <i>Jean-Philippe Lang</i></li></ul><p>Committed, thanks.</p>