# Creating a rails 3 app generator executable using thor

**URL:** <https://discuss.rubyonrails.org/t/creating-a-rails-3-app-generator-executable-using-thor/48930>\
**Category:** rubyonrails-core\
**Created:** [January 28, 2010, 4:48pm UTC](https://discuss.rubyonrails.org/t/creating-a-rails-3-app-generator-executable-using-thor/48930 "2010-01-28T16:48:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kristian1](https://avatars.discourse-cdn.com/v4/letter/k/73ab20/32.png) [@Kristian1](https://discuss.rubyonrails.org/u/Kristian1)\
**Post date:** [January 28, 2010, 4:48pm UTC](https://discuss.rubyonrails.org/t/creating-a-rails-3-app-generator-executable-using-thor/48930/1 "2010-01-28T16:48:26Z")

</div>

For inspiration I have been looking into rails 3.0pre

I found this in the file bin/rails

---

<div class="post-metadata">

**Author:** ![Kristian1](https://avatars.discourse-cdn.com/v4/letter/k/73ab20/32.png) [@Kristian1](https://discuss.rubyonrails.org/u/Kristian1)\
**Post date:** [January 28, 2010, 5:40pm UTC](https://discuss.rubyonrails.org/t/creating-a-rails-3-app-generator-executable-using-thor/48930/2 "2010-01-28T17:40:10Z")

</div>

except I run into the following issue

module Nifty &nbsp;&nbsp;module Generators &nbsp;&nbsp;&nbsp;&nbsp;class ScaffoldGenerator \< Base ... &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def initialize(\*args, &block) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;args\_for\_c\_m.each do |arg| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if arg == '!' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options[:invert] = true \<\<\<\<\<\< line 53 ... &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if @model\_attributes.empty? &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options[:skip\_model] = true \<\<\<\<\<\<\<\<

end

---

<div class="post-metadata">

**Author:** ![Kristian1](https://avatars.discourse-cdn.com/v4/letter/k/73ab20/32.png) [@Kristian1](https://discuss.rubyonrails.org/u/Kristian1)\
**Post date:** [January 28, 2010, 10:17pm UTC](https://discuss.rubyonrails.org/t/creating-a-rails-3-app-generator-executable-using-thor/48930/3 "2010-01-28T22:17:19Z")

</div>

I fixed it with a pretty ugly hack 😛

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def initialize(\*args, &block) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@my\_options ||= {} ... &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if arg == '!' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@my\_options[:invert] = true ... &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if @model\_attributes.empty? &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@my\_options[:skip\_model] = true

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def do\_skip\_model? &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options.skip\_model? || @my\_options[:skip\_model] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def do\_invert? &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options.invert? || @my\_options[:invert] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def create\_model &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unless do\_skip\_model? ...

I'm sure there must be better ways around this!

I have also managed to create executables for all my generators!

[http://github.com/kristianmandrup/very\_nifty\_generators](http://github.com/kristianmandrup/very_nifty_generators)

Enjoy!
