Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Too many questions here to answer them all properly. This is one of those things that will pay off for you by just digging in and trying it out. As you get deeper into it, come back and ask new specific questions. </p> <p>Here are some of the resources I used when I recently did this.</p> <ul> <li><a href="http://www.themodestrubyist.com/2010/03/05/rails-3-plugins---part-2---writing-an-engine/" rel="noreferrer">http://www.themodestrubyist.com/2010/03/05/rails-3-plugins---part-2---writing-an-engine/</a></li> <li><a href="http://www.themodestrubyist.com/2010/03/16/rails-3-plugins---part-3---rake-tasks-generators-initializers-oh-my/" rel="noreferrer">http://www.themodestrubyist.com/2010/03/16/rails-3-plugins---part-3---rake-tasks-generators-initializers-oh-my/</a></li> <li><a href="http://pragprog.com/titles/jvrails/crafting-rails-applications" rel="noreferrer">http://pragprog.com/titles/jvrails/crafting-rails-applications</a></li> <li><a href="http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/" rel="noreferrer">http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/</a></li> </ul> <p>For the most part, you can keep the things in your app directory where they are. You should also be able to keep your <code>routes.rb</code> in the config directory, but there can be some gotchas if some of your routes collide with those of the app.</p> <p>You will likely want to create a <code>generator</code> to create a migration that has all of the tables your engine requires. Other generators can be created to override default views and that sort of thing.</p> <p>Do create a test application that uses your gem. Many of the issues you will run into are making sure you are loading your engine's dependencies properly. While you are in development, edit the Gemfile of your test application to point straight to the source of your gem... something like this:</p> <pre><code>gem 'my-forum', :path =&gt; '~/work/my-forum' </code></pre> <p><strong>Namespacing</strong></p> <p>You should at least name your tables/models so you don't run into naming collisions. Looking at your current forum app, I'd at least prefix all of your tables with 'forum_'. It is quite likely that someone using your engine will have a different model named <code>Category</code> for example... so <code>ForumCategory</code> would be a better choice.</p> <p>Definitely namespace any classes you create in the lib directory.</p> <p><strong>Config Files</strong></p> <p>You'll want to keep your <code>routes.rb</code> in the config directory. You may also need to keep your initializers around as well. Any app specific things will likely need to get moved elsewhere.</p> <p><strong>Public Files</strong></p> <p>With Rails 3.0.x, you can keep stylesheets and javascripts in the public directory. I think there is a bit of code you need to add to your <code>Engine</code> class though...</p> <pre><code>initializer "static assets" do |app| app.middleware.use ::ActionDispatch::Static, "#{root}/public" end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload