# Rails 3 Plugin v Gem using /app

**URL:** <https://www.ruby-forum.com/t/rails-3-plugin-v-gem-using-app/195789>\
**Category:** Rails\
**Created:** [September 30, 2010, 8:20am UTC](https://www.ruby-forum.com/t/rails-3-plugin-v-gem-using-app/195789 "2010-09-30T08:20:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [September 30, 2010, 8:20am UTC](https://www.ruby-forum.com/t/rails-3-plugin-v-gem-using-app/195789/1 "2010-09-30T08:20:57Z")

</div>

I’m accustomed to making plugins for Rails 2, and recently updated those  
for Rails 3 (minor differences in structure). Spent most of this week  
figuring out how to make most of those gems.

One of them I am having trouble with – this one involves an /app  
directory with some helpers and some views. It has worked great as a  
Rails2 and even Rails3 plugin. As a gem, I can’t seem to get Rails to  
see the files in /app.

I’ve been using jeweler. I don’t use git, so I have been manually  
specifying files like this:

Jeweler::Tasks.new do |gem|  
#…  
gem.files.include(‘app/**/\*.rb’)  
gem.files.include('lib/**/\*.rb’)  
#…  
end

That’s apparently not enough. The code in the gem works until the main  
app hits something needed from the gem’s /app folder.

I’m missing something. Googling and trial & error are failing me.

What clue say ye? Thx.

– gw

---

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [September 30, 2010, 10:58am UTC](https://www.ruby-forum.com/t/rails-3-plugin-v-gem-using-app/195789/2 "2010-09-30T10:58:20Z")

</div>

Devise ( [GitHub - heartcombo/devise: Flexible authentication solution for Rails with Warden.](http://github.com/plataformatec/devise/) ) adds some views,  
controllers and helpers so you can look at the code. Maybe you are  
missing the fact that you need Rails::Engine ?  
[devise/lib/devise/rails.rb at main · heartcombo/devise · GitHub](http://github.com/plataformatec/devise/blob/master/lib/devise/rails.rb)

I think that Yehuda K. has a post about it.

Robert Pankowecki

---

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [September 30, 2010, 6:36pm UTC](https://www.ruby-forum.com/t/rails-3-plugin-v-gem-using-app/195789/3 "2010-09-30T18:36:05Z")

</div>

Robert Pankowecki wrote:

> Devise ( [GitHub - heartcombo/devise: Flexible authentication solution for Rails with Warden.](http://github.com/plataformatec/devise/) ) adds some views,  
> controllers and helpers so you can look at the code. Maybe you are  
> missing the fact that you need Rails::Engine ?  
> [devise/lib/devise/rails.rb at main · heartcombo/devise · GitHub](http://github.com/plataformatec/devise/blob/master/lib/devise/rails.rb)

Thanks for the example. Interesting that it doesn’t use the same pattern  
as all the blog posts I can find use (re: engines.rb file). Hmmm…

– gw

---

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [October 1, 2010, 7:45pm UTC](https://www.ruby-forum.com/t/rails-3-plugin-v-gem-using-app/195789/4 "2010-10-01T19:45:31Z")

</div>

Keith S. wrote:

> Greg, I have a working example that covers a bunch of gem features, it  
> might help you:  
> [Keith Schacht – Medium](http://keithschacht.com/creating-a-rails-3-engine-plugin-gem/)

OK, so to make use of a /app folder, the gem must be an engine.

Keith, I’ve been using your example (thanks) and about a half dozen  
articles, but still running into problems having the contents in the  
/app folder get included using this:

Jeweler::Tasks.new do |gem|  
#…  
gem.files.include(‘app/**/\*.rb’)  
gem.files.include('lib/**/\*.rb’)  
#…  
end

I’ve converted almost a dozen of my plugins to gems (so I seem to have  
that pattern at least emulated well (if not yet fully understood)), and  
now need two engines. I have one sort of working. The basics all work,  
so I have the engine.rb part worked out, but it is still missing some  
/app folder content after I create the gem.

I think I just spotted a pattern. In this line,  
gem.files.include('app/**/\*.rb’)  
I am not familiar with /**/ but I’m now seeing that in the /app folder,  
a layout like this:

So,  
/app  
/models  
model1.rb  
/views  
/red\_stuff  
red1.rb.rb  
/blue\_stuff  
blue1.rb.rb

in my installed gem I see /models but not /views – and I think that’s  
because /views doesn’t have any .rb files in it.

So, I think the root of the problems I’m seeing is understanding the  
files.include() part of jeweler to get what I need (Note: I am not using  
git).

Looking at the ruby gems docs, I don’t see any examples of files.include  
– so it’s still confusing as to which of these settings commands use  
gem syntax and which uses jeweler syntax.

– gw

---

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [October 1, 2010, 10:21am UTC](https://www.ruby-forum.com/t/rails-3-plugin-v-gem-using-app/195789/5 "2010-10-01T10:21:15Z")

</div>

Greg, I have a working example that covers a bunch of gem features, it  
might help you:  
[http://keithschacht.com/creating-a-rails-3-engine-plugin-gem/](http://keithschacht.com/creating-a-rails-3-engine-plugin-gem/)

---

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [October 1, 2010, 7:56pm UTC](https://www.ruby-forum.com/t/rails-3-plugin-v-gem-using-app/195789/6 "2010-10-01T19:56:06Z")

</div>

> So, I think the root of the problems I’m seeing is understanding the  
> files.include() part of jeweler to get what I need (Note: I am not using  
> git).

Oi! What a moron.

gem.files.include(‘app/\*\*/\*.rb’)

There are no .rb files in /views!

gem.files.include(‘app/**/\*.rb’)  
gem.files.include('app/**/\*.erb’)

catches them.

Major thwak to the forehead.

– gw

---

<div class="post-metadata">

**Author:** ![S-gw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@S-gw](https://www.ruby-forum.com/u/S-gw)\
**Post date:** [October 2, 2010, 5:31am UTC](https://www.ruby-forum.com/t/rails-3-plugin-v-gem-using-app/195789/7 "2010-10-02T05:31:22Z")

</div>

Ah, I didn’t catch that in your post either. Glad to see you figured  
it out!
