Rails application templates [closed] - ruby-on-rails

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 know 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.

Related

Share code/configurations/conventions/gems between Rails apps

THE PROBLEM
First a little bit of context: I am currently working as a freelancer, developping webapps using Ruby on Rails. Because I am working solo, the need to optimize my workflow is pretty important.
That's why I have always had the same question since I begun working with Rails:
How can I share code/configuration/conventions/tests between my apps?
More precisely, I want to share:
common gems that I always use, with their configuration
common integration tests, to ensure some conventions
common view helpers, test helpers, extensions to the core classes, javascript/sass partials
common files: .gitignore, git hooks, .eslintrc, configuration files of my CI etc
Some concrete examples of what I need in all my apps:
disable turbolinks by default, to add it later if need be
use javascript instead of coffeescript
use slim instead of ERB
install/configure capistrano
install a CSS framework (bootstrap, bourbon + neat + refills)
So far I don't really have the need to share models nor controllers.
I don't want to share behavior or functional components of the system itself, I am not looking for a micro-services architecture.
I have found that so far when creating new applications, all this setup work does take me a lot of time. Also, I would like to apply it retro-actively to existing apps when I add something new.
I have done quite a bit of research, but I haven't found a lot of answers. Many people are trying to share models, but few people seem to want to share a common ground between all their apps. Finding the right keywords may have been the problem though.
It seems to me that Rails is really good at DRY within an application, not so easy when trying to DRY between applications.
POSSIBLE SOLUTIONS
1 - Rails application template
The solution I am using right now, described in the Rails Application Templates guide, using the same API than the Rails generators described in the Creating and Customizing Rails Generators & Templates guide.
That's the solution used by Thoughtbot, with their popular suspenders gem. In the case of Thoughbot though, they have years of experience to draw from, have many employees and their common setup does not change that much.
Pros:
saves a lot of time when creating a new application
really nice API
Cons:
a lot of duplication: all the apps have the same common code, with the problem of this code getting out-of-sync
not retroactive: useless to add a common feature to already created apps
heavy maintenance work: my current workflow is to go through the git log of my apps once per month, and for each commit that could be common to all the apps I have, add it to the application template, and add it to the other apps manually
So far this solution is not that bad, because I only have two applications. But once I will have more, I will suffer from more and more overhead.
A better solution would be maybe to create a generator/rake task for every common new feature, to be able to apply it quickly to existing apps, and call it directly in the application template for new apps.
I haven't tried it though, and I am not really sure it will work. For example what if I want to propagate a one-line change in an existing common file in all the apps?
2 - Rails Engine
I have tinkered a bit with the Rails Engines to share code.
I have not understood from the Getting Started with Engines guide if I should better use a --full engine or a --mountable one for this specific purpose.
Pros:
once I update the gem version, all the changes are made available to the app
DRY: all the common code is in a unique place (the gem)
Cons:
the gems I would like to share are put in the *.gemspec file, which has not as many features as the Gemfile (from what I understand)
overhead caused by the need to update the version of the gem in all the apps, migrate to the new API of helpers, etc
no way to share non-rails files (.gitignore, git hooks, .eslintrc)
This solution has too many important shortcomings.
3 - Hybrid solution: Rails Application Template + Rails Engine
Maybe the best would actually to use both the above solutions.
In the gem share helpers and tests, in the rails template share the gems, their configuration/files and other files (for git, linters, etc)
It is indeed adding more complexity and overhead...
4 - Use git subtrees
Some people use git subtrees to share folders between multiple webapps.
Cons:
one has to share whole folders, not easy to share everything I would need, in their different target directories in the rails app
seems a bit "hacky" to me
Conclusion
Is there another solution than the ones I mentionned above?
What do you think would be the best way to do it?
How about having a blank "Master" rails app in the git somewhere. With all the settings and configurations you'd like to share. When creating a new app from scratch, you can merge the "Master" into it to apply the defaults. When you have an existing app, same thing, just merge and resolve conflicts as needed.This also gives you the ability to override the merged code if needed to.
Few things I can see wrong with this approach though:
Rails application name could cause a lot of headaches
Any updates could cause merge conflicts
I created a tool to deal with this when working in nodejs projects. But the tool is really just a command line tool so you should be able to use it.
https://github.com/tomasbjerre/dictator-builder
It is a concept with creating a dictator that dictates parts of your code base.

Ember.js and Ruby on Rails: Strategy [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I need to develop an interactive web app with an admin backend. I have thought about using Ember.js for the frontend and Ruby on Rails (with ActiveAdmin) for the backend.
But i have some questions:
1) Should i put the Ember.js app inside the rails project, or having both separate? Is there any performance difference or something i should know about choosing one of the two strategies? I like to have things as clear as i can.
2) Should i use Ember.js and Rails-API instead? I mean... i think i won't use almost anything about the Ruby on Rails project... But i am confused, as i need the Admin Backend...
I have some experience (a little) on Ruby on Rails, but as i am new to Ember.js, i would really appreciate any help you can give me.
I also worked on a similar kind of project, and believe me having two different projects will benefit you a lot.
I used followings:
Sinatra for backend
Backbone.js for frontend
It makes a lot easier to add the functionality in your code, when you use two separate apps.
I recently had a similar project with an Angular app and a Rails backend. I agree with Arslan. Having a Sinatra, Rack or other API is better than Rails.
Using Ember for some parts, and Rails for other parts (like the Admin section) is a bad idea because:
You are doing the same things 2 different ways: getting data, rendering pages, etc.
You would have 2 separate functionalities in within the Rails app: one Rails app and one API.
It is much simpler to run 2 separate apps than to put a Javascript MVC into a Rails app. You end up with complexity in getting the Asset Pipeline to do what you need.
Here's my take:
If you're fluent in Rails, stick with Rails.
Yes, Sinatra or other frameworks may be lighter, but you'd have to handle lots of things by yourself.
As for Rails-API, it's a good project, but it's a bit of hassle at the beginning to figure out what modules were removed, etc. You can make an API with Rails without Rails-API. You can always use Rails-API at a later point if it turns out you need the performance increase.
Use Ember CLI for your client application.
It's the golden path for developing ember applications and using third party libraries. The gem Ember-rails still works and is still maintained, but you should not start a new project with it.
Keep them separate
It simply makes more sense to have them separate. This way, development and deployments of both apps are not tied to each other.
It uses more repositories though, and if you're using github, it may mean you'd have to switch plans. But there are other options such as bitbucket where the pricing is not tied to the number of private repositories
I hope this helps you.

Is Ruby on Rails good choice for my next web-app? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
When I am writing this, I must admit that I am already inclined towards RoR.
I have gone through official "Getting Started" tutorial and created a sample RoR app.
I have also had glance through guides.
While creating sample app, I loved the ways Rails auto-generate a whole lot of code for me, and creates a nicely organized directory structure.
Creating simple sample app is fine but now I have following questions before choosing RoR for enterprise web app.
Following are question in my mind.
How would I debug my app? While working on Java + Spring, we could step through in Eclipse, read about ruby-debug which is like command prompt debugging. Aren't there any IDE debuggers?
How would I combine all javascripts etc? in Java=Spring framework I had earlier used Google closure template for minification and joining all javascript files. would it allow sourcemap support?
Image Spiriting ? Any quick link to just look through if its possible or not?
Authentication and security : I am sure it must be possible in Rails to get logged in user's profile and then check what are db objects we can view and update, it will specific to one's web-app. Can anyone give some links, to just look through if its possible or not? can we protect the URL based on roles as we can do in spring? How do we integrate FB/Google login
Templating : While creating sample app, realized that Rails supports templating in html through embedded ruby tags, thats cool but having seen it work two more questions.
5.1 : :construct like :confirm etc would depend on jquery_ujs.js, thats perhaps
shipped with rails, but I may not want to 'jquery_ujs.js' I may have my own
different styling for modal dialogs. How do i replace jquery_ujs.js and plugin
something else ?
5.2 : app->view->layouts->application.erb.html , allows you to setup up title of all
pages and what goes in header of all pages.
But I may not want the same title and header for all pages of my web-app,
It would be different for each page. How do we do that in rails?
DB : most probably I am going to use DynamoDB as and use memcache for caching,
Any simple and sample code for pluging in the memcache in rails for dynamo
Maintaining three environment: How to we maintain three different environment in Rails, Production, staging and dev
Would i be able to use less instead of css?
As everything, there are more than one way to approach to every single question.
I usually use pry-remote to debug my rails application, because I use pow server and I use Sublime Text, but RubyMine is a nice IDE for developing Rails apps and it has a build in debugger.
Sprockets takes care of this and it's integrated in Rails. I use SASS and CoffeeScript, and you can generate source maps easily for them using those gems - sass, coffee
You can use Compass to generate image sprites pretty easily. (Check out this episode on Railscasts - Compass & CSS Sprites
Devise gem is really popular solution for authentication and for the Facebook/Google+ you can use OmniAuth which integrates nicely with Devise. And for authorisation, a really popular solution is Pundit gem.
You are free to use whatever JS UI library you like and for the dynamic layout content you can use content_for helper. You just have to add yield :page_title in your layout and then, call the content_for :page_title { 'Specific title' } in your views.
For this question, I don't have an answer but I am pretty sure that there is a gem that can help you with this like Dynamoid for example
Rails supports different environments out of the box (testing, development, production) and you can easily add your own ones.
Rails has a support for SASS out of the box, but you can easily switch to LESS. Check out less-rails gem.
Rails is pretty mature framework and the community around it is pretty good, so you can easily find a gem that can help you solve specific problem. And there are quite a lot resources around the internet.
Good luck :)
i will give a short glance
ANSWER-1
There is no such debugger like eclipse for ROR, you can use sublime_text editor for editing, Rspec is nice tool for RoR.
Answer-2
In RoR there is no need to combine all js files,you can write any of the .js file it will be render to application.js default
Answer-3
Link to question
Answer-4
There are gems in RoR which wil easily help you to do stuffs like authentication, omniauth etc..
RUBYGEMS
Answer-5
There are many ways you can easily find out asking on stackoverflow for your problem.
Suggession:
Instead of asking many question you should try to learn ruby deeply you will easily get your answers.

Is there a quiz gem for Ruby on Rails?

I'm looking for a simple quiz gem in Ruby on Rails. It needs to present the user with multiple choice questions (radio buttons, checkboxes only), tally up the right/wrong answers, and display the results at the end. The quiz will be about 25 questions - 1 question per page. It also needs to integrate with the site I'm building, so it can't be a standalone site, or third-party site.
So far I've found this gem, which looks promising:
https://github.com/NUBIC/surveyor
Anyone know of any other Quiz gems in Rails?
The surveyor gem is quite powerful and I can recommend it. There is one thing that you should note: you write the survey in a dsl (ruby file with special, easy to understand syntax) and then run a rake task. This means that it's very useful for a one-off survey, where a developer can generate it (much easier and faster than doing it manually), but not if you want a non-technical person to generate surveys on her own.

Extracting a Rails application into a plugin or engine

I have a Rails 2.3 application which I would like to extract into a plugin, or engine. The application has user authentication, and basic cms capabilities supported by ancestry plugin.
I want to extract the logic for the application into a plugin/engine so that I can use this code for future projects, with a different "skin" or "theme" if required.
I'm not entirely sure I actually understand the difference between plugin and engine concepts, so that would be a good first point.
What is the best approach, are there any good starting points, links, explanations, examples that I should follow. Also, with the release of R3 to consider, is there anything that I should be aware of for that, with regards to plugins etc.
I am going to start off by watching Ryan's http://railscasts.com/episodes/149-rails-engines
but obviously thats over a year old now, so one of the challenges I'm faced with is finding the most up to date and relevant information on this subject.
All tips and help gratefully received.
Actually, converting an application is pretty straigtforward. Just create a plugin-folder, put an app-folder inside containing all yor model-views-controllers folders, and that's it.
You will have to manage your migrations yourself though. Also you have to define rake-tasks to copy files to your public folder. I think the railscasts is still pretty up-to-date, if anything it is now easier in rails 2.3.
Good luck!
[EDIT: for rails3] Rails 3 engines are very clean and powerful. Check this gist by Jose Valim.
You will probably be better off focusing your engine on Rails 3, as opposed to trying to make it compatible for Rails 2 and Rails 3, due to the backwards incompatible changes. Here is a more up to date tutorial for Rails 3
also the book "Crafting Rails applications" by Rails Core member Jose Valim, has a good chapter on it. Int he shows how to use his tool EngineX which generates a Rails 3 engine structure, so you can more easily create engines for your Rails 3 projects. His gem devise is also a rails engine which is also nice, because you can easily customize it by copying the templates into the application directory, and allowing you to subclass the controllers that you want to customize more.
Writing a plugin is an entirely different process than writing an app, if you already have your app code it should be straightforward converting it into a plugin.
Consider that if you use third-party plugins in your app it could get pretty messy.

Resources