开发者

Rails application templates [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 4 years ago.

Improve this question

I am starting to learn Ruby on Rails. I have an application in mind that I would like to create, but I kno开发者_如何学Cw I'm going to have to repeat a lot of the things that have already been done a million times (such as user authentication, etc).

I just found out about rails templates. From what I understand, you can use one of these templates to create a new rails application and set up a lot of the basics. Where can I find some of the most popular templates, and should I use one of them?


Andrew, if you are starting to learn RubyOnRails and have an application in mind, I suggest you DO NOT use any templates at all and do it by hand.

Rails templates primarily pull in gems and other external dependencies (plugins) into your app. The primary benefit of templates is for people who build so many Rails apps so often that they'd like to get bootstrapped really quickly.

You would learn more and feel much more confident about the whole process if you consciously chose the plugins/gems you need and progressively added them to your app.

Devise (popular authentication gem) goes so far to say, that if you are starting with Rails app, you should NOT use it.


Here's a more current answer which applies to Rails 3 (the other answers are all from January 2010).

After playing around with editing application templates for a few months, I've found it can be a headache to assemble and maintain a application template. It helps to have a collection of "recipes" that can be maintained individually, then assembled into an application template.

I'm using the

rails3_devise_wizard

which is a version of the RailsWizard gem with custom recipes for a Devise starter app.

I've used it to create two application templates:

Rails 3 + Devise + RSpec + Cucumber Application Template

Rails 3 + Devise + RSpec + Cucumber + Mongoid Application Template

which generate the following example apps

Rails 3 + Devise + RSpec + Cucumber Example App

Rails 3 + Devise + RSpec + Cucumber + Mongoid Example App

and each has detailed tutorials showing how they're built:

Rails 3 + Devise + RSpec + Cucumber Tutorial

Rails 3 + Devise + RSpec + Cucumber + Mongoid Tutorial


Jeremy McAnally maintains a diverse collection here: http://github.com/jm/rails-templates/

I don't think there are any silver bullets, but they display a lot of techniques that templates allow.


Rails Kits may also fit your needs, even though they're not actually Templates:

http://railskits.com/available-kits/


There are several ways to extend a Rails application and/or start one off. You've mentioned just one of the big four. The others are:

  • Plugins
  • Engines
  • Gems
  • Templates

Templates are generally used to start out an application, but if designed correctly, you can use them to extend one. For example, many stock templates out there help setup a code repository, install a few plugins/gems, and perhaps fix up the layout a little so you don't have to. Of course, you'll usually do most of these when you first start out a project. At our company (3 developers) I created a template that sets up our dev and production environments, repositories, project tracking. Here's my favorite stock template: http://github.com/lhoeg/app_lego/network (The original hasn't done much work on it in a while, and I believe this is the best fork out there now)

Plugins and Gems are more or less becoming synonymous and there's little reason any more for people to create plugins, as gems are the more Ruby-standard way to package functionality. Generally you'll use plugins to add bits of very specific functionality to your application. This can range from adding user authentication, to calendaring, to adding locations and mapping to your app. Most plugins that I've used extend the ActiveRecord or database part of the application. If the plugin comes with views, controllers, or modifies your database tables it'll usually come with a generator. A good example is the Restful Authentication plugin's generator. A relatively good list of http://agilewebdevelopment.com/

Engines are the kings of modularity. They usually provide a lot more functionality than plugins. Whereas plugins and gems generally extend Rails itself, Engines are intent on extending YOUR application by adding a full set of views, controllers and models. Thus engines are entire Rails applications packaged into a neat little box that you can just plop into your app and instantly add a bunch of functionality. There's also an Engines directory at http://agilewebdevelopment.com/ but as you'll see, there aren't very many.

Hope this helps!

Berns


Try to search on github, there are really a lot of cool stuff. http://github.com/search?langOverride=&q=rails-templates&repo=&start_value=1&type=Repositories

If you search a example of authentication try to search a authlogic-example on github.


Ryan has some Rails templates: http://github.com/ryanb/rails-templates

It seems Jeremy's repository gave me a 404 when I tried it.


We have developed a Rails application template.

https://github.com/agilie/Rails-Application-Template

For now it contains testing, deploy, documentation generation functionalities, sidekiq, redis and much other gems and stuff. It is fully customizable and you can easily enhance it for your needs. Feel free to fork and make some pull requests.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜