Rails project that is actively updated as a base - ruby-on-rails

I'm currently researching how I can create a standard rails project with some custom functionality as the basis for my next projects.
I know there are some tools for templating (http://guides.rubyonrails.org/rails_application_templates.html) a project but I don't know if they will suffice as I want to keep updating the template project with new stuff.
What are the ways to achieve this? Will git be the solution (rebase the new functionality) or is there anything else that is easier to manage?

Can you give more information on what you're trying to achieve? You're a bit vague to be honest.
I don't see why templating wouldn't work
You could combine it with a generator, installed through a simple gem you've created that's defined in a Gemfile somewhere
remove_file 'Gemfile'
copy_file '/path/to/Gemfile', 'Gemfile'
run "bundle install"
generate("your_generator:install")

Related

How do I include new gems that are automatically there whenever I create a new rails app?

Usually, I paste the gem code in the gem file and bundle install. But I realised I have multiple gems I use over and over. How do I include those gems automatically whenever I create a new rails app?
Any help appreciated. I'm still new. Thank you
I have a starter template for new rails apps that I use. Basically has my testing gems ect. and certain folders that I like created in each. Basically rather than rails newing I will just clone the starter repo.
I think he might be referring to just having an initial app that you can clone yourself like copy+paste
It's a nice idea, but I don't know an automated solution to this.

Nesting Ruby gems inside a Rails project

How do I create a gem project nested inside my current Rails project?
I've got a Rails project with several parts that could easily be gems. I would like to extract these parts into gems but not leave the current Rails project. Creating new source control repos for the gems add additional complexity that project or organization is not ready or able to handle. These complexities will be overcome at some point and I would like to be ready.
So far I can only think of these items.
Relocate code to a single directory root. I'm guessing this would be in the vendor path
Create a <something>.gemspec
Link to the gem in the Gemfile of the Rails app
gem 'my_lib_code', path: 'vendor/my_lib_code'
What else do I need to do? I'm sure I'm missing something important.
If this were a c project I would create another shared library that the make process spits out. Or if this where a c# project I would make a .dll. For Java I would...
I'm sure Ruby can do the same as all the other languages. Something that is a half way step between a normally fully extracted gem and just some code siting in my lib path.
This is a perfectly fine approach for a component-based architecture.
You have a single repository, a single test suite, and a single deployment process, while at the same time you are "forced" to think of clean interfaces and separation of concerns.
Of course if you are planning on sharing this functionality with other projects, an externally hosted (but not necessarily public) Gem would serve better.
Implementation wise, you can get some nifty ideas from Stephan Hagemann's talk at this year's RailsConf: "Get started with Component-based Rails applications!"

Is it possible to create a self contained ruby on rails package?

I'm currently looking into what language to build a web application on that will be sold to companies. To make things easier, I was hoping to package the webapp into a convenient installer that contains the entire stack which will run automatically.
Is there any way to create a self contained RoR package?
The only project I'm aware of is called pkgr, which bundles an entire rails app into a DEB package. So if you don't mind limiting your installs to Ubuntu/Debian, you could give it a try.
pkgr home page
Github
You can write a rake task to automatize everything for you. Migrations, bundling, enviroment setup. And it's pretty much plain Ruby, too.
In the end it would be just running a script file to do the job.

What would be ideal way to share functionality between Rails apps?

I have a number of view helpers I use on almost every project, a set of useful rake tasks, minor extensions to active record, extensions to some gems (inherited_resources).
I'm wondering, what would be a good way to manage these 'snippets'? I wouldn't want to manage a gem for each snippet, or even a gem for each 'type' of snippet. Would it suffice to bundle this into a personal gem? Maybe add the option to specify which helpers/extensions to include in the project?
I could use a 'template' application which I could bundle with this code, but the problem here is if I update a snippet on one project, I want to be able to rollout that update on all projects with minimal effort (i.e. bundle update).
With your requirements, I would bundle it all in a base-zenph-gem and use it in every one o your projects, as it is the best way to have synchronized code over different projects.
Also, make a good documentation for it, as if anyone inherits one of those projects would love to know what is going on.
Instead of a gem with Rails you can create an engine which contains reusable functionality, then you can specify the use of the engine within your applications.
You can read more about it in the Rails documentation: Rails Engines

How to create a project template for Ruby on Rails projects?

When I build Rails applications I find myself doing the same things over and over again. This includes adding the same gems/plugins, configuration info and custom initializers, rake tasks etc... etc....
This can't be a good thing.
So, is there a way to package all this repetitive code into some sort of project template ... so that I can do a "rails myapp" and have everything good to go from there?
Btw, running 2.3.5 if that matters :)
thanks
App templates is probably the feature you are looking for.
Many people just create the "template" and then commit it to a repository, possibly on GitHub, for easy access later. I personally find that this works really well.

Resources