When Rails require mod_rails, what about Django, TurboGears, Symfony, CakePHP? Can they deploy using mod_python and mod_php? - ruby-on-rails

When Rails applications seem hard to deploy (or used to be), what about Django, TurboGears, Symfony, CakePHP -- can they be simply deployed using mod_python or mod_php? Actually, won't it need something like a mod_django so that the code can run in a "Django" environment? (Just like Rails' script/console or Rails 3's rails console)

Django applications can certainly be deployed with minimum fuss using mod_python.
That said, experienced people will tell you to use the more lightweight and efficient mod_wsgi instead of mod_python. This too can be done with minimum effort. I have done it on multiple occasions and app deployment was always the least of my worries.
Update
#Rebus has it right:
mod_python is not being actively developed anymore, use mod_wsgi

There are a number of ways to deploy a Django site. See the Django Docs or the Django book. As mentioned mod_python is dead and mod_wsgi is the recommended method. Another method which has been making more noise lately is gunicorn. You can see Eric Holscher's blog post about how easy the deployment can be with it.

For CakePHP if you have a standard PHP installation, you probably, at most, only need to load mod_rewrite. This module is often included in the build, though.

Related

Rails Webpacker or Vue-CLI?

I'm building a Single Page (Web) Application. I'm quite smitten by Rails v5.0, especially its built-in API capabilities.
In the past I've built JavaScript frontends using Vue.js, usually with the templates provided by the Vue-CLI project. This allows deployment of Vue component-based static sites basically anywhere. It's great.
Now, Rails 5.1 has some built-in Webpack and Yarn features which look pretty compelling too. I'm not sure how to proceed with my new application.
My questions:
What are the pros/cons of integrating Webpack and Vue into Rails itself, using the Webpacker extensions available in Rails v5.1? I
intend to deploy to Heroku.
On the other hand, what are the pros/cons of using the Rails API-only mode for the backend, and maintaning the Vue/Webpack-based
frontend in its own directory? I'd keep everything in the same
repository, deploy the backend via Heroku, and the frontend via a
static host like Netlify.
Which approach would have more cognitive overhead or technical complexity?
Over the past few days, I've been looking around, and I've not found much concise information on the web about this. People seem interested in the auto-reloading features of the Rails development environment, but I get that for free already with Vue-CLI.
As far as I can discern, these are reasons for keeping them separate:
Deployment of the frontend is pretty darn simple to anywhere.
The Webpacker mode for Rails is very new, and not many tutorials or guides exist yet, especially regarding integration testing. Keeping
things separate means that my existing testing apparatus should still
apply.
Here are some pros for integrating the two parts together:
The possibility of using static assets both for the frontend and possibly for server-generated pages in the future, should that be
necessary.
Buy-in to "the Rails way", with implied future maintenance by the Rails team.
the JS Frontend would not need to be hosted separately.
Don't need to worry about CORS (?)
What other concrete benefits exist for either approach?
When i started i went the webpacker way, somewhow because that's what it looked like it was "supposed" to be. As you say, very little guidance.
Webpacker (with it's reliance on the latest node) seems a moving target, making deployment and even development more complex. For what benefit i asked and got rid of it.
Now i use vue from the cdn. Benefits:
cached close to user
almost zero installation
easy to have dev/production versions
The i write app code into the rails templates. Using haml, and in fact ruby2js, but you can use javascript just fine. That's how i started, but i like ruby, and the ruby code is almost half the size than the generated js, but i'm getting off track.
So templates are your "vue annoted" rails templates.
Small code also goes into the rails template.
More code can be defined in the assets and referred to from the app.
Even components can be written into template using the x-template syntax.
And last but not least: Data can be transferred by to_json, directly into the templates. And in the same render. Much faster than an additional query. When to_json is not enough one can use rabl to get exactly what is needed.
I hope i made that clear. I am in the process of writing some vue-rails stuff up, as there is so little to be found. Look out here (and i'll comment when the post is ready)

How to set a minimal Ruby page on a webserver that can add / edit / delete records?

I am trying to add a page on dreamhost.com to display
record = Record.find(params[:id]) # such as Record.find(1)
print record.content # to show content of this record
and that's it... probably using sqlite or mysql, and want to have the ability to add a record, similar to Ruby on Rails's scaffold.
If using Ruby on Rails, it is probably too big for such a simple purpose, but if I use Sinatra, then it looks like I have to start it on a port (and can't start it on port 80 because it is the dreamhost.com's port)
Can Sinatra or any tool or framework fit this purpose?
Go with Rails
Dreamhost offers Rails already installed and at no extra cost. And knowing Rails will certainly be more useful to you in the future than knowing Sinatra.
So, I don't see the benefit in Sinatra unless you are hosting the server.
Since Rails is a framework, it will give you a basic application easily, despite it's massive internal complexity.
I know this doesn't exactly answer the question, sorry about that, but on a shared-hosting site you will have limited opportunity to fiddle with the configuration. It's easier in this case to go with Rails.
Rails isn't really that heavyweight. Unless you need your "app" to be very high performance, Rails is probably a good solution that'll let you have this up in a matter of a couple hours.
That said, I'm sure Dreamhost has a way for you to run a Sinatra app within Phusion.
I wonder why nobody mentioned Padrino yet. It is lightweight and provides you with a simple admin interface!

What is the limit of Sinatra?

I've been learning the Ruby web framework Sinatra lately, and I'm finding it great to use. Most of the articles and blogs I have read about it seem to assume that it is good only for small websites, or 'tiny' web-apps. Is this true? Can a complete web application be built in Sinatra, or is Ruby on Rails the way to go?
You could, in theory, build an entire web application using Sinatra, and it would offer you more precision control than Ruby on Rails would.
That said, it also removes all of the nice features ruby on rails gives you, such as the Model-View-Controller architecture.
If you're looking to build a web application with database interaction, I strongly advise you use Ruby on Rails.
If you're looking to build a very simple API or something that just takes some data and throws it up onto Twitter or something, go ahead and use Sinatra.
There is no reason that it couldn't be used to build an enterprise website. It's fast and intuitive. Two key things in building a larger web application. While it does lack many of the features of Rails, I am yet to run into a road block.
I personally like the slim nature of Sinatra. It embraces routing instead of making it a headache.
I usually find myself wrestling with Rails, whereas I configure Sinatra to my liking.
As for database interaction, mongo_mapper + Sinatra works very well.

Ruby Based Blogging Engine

What Rack enabled blogging engines exist? I want to deploy a free blog to heroku and need more customizabilty than the free hosting of Wordpress.com or Blogerty provide.
Also in another note, has anyone tried to port Wordpress to Ruby?
In any special order:
== Rack based
toto
ruby-slippers based on toto
== Jekyll based
Jekyll itself
Octopress blogging in jekyll
spinto jekyll cms
prose jekyll cms
== Rails based
typo one of the oldest in active, with more features but more complex
enki for hackers, basic code
simplelog just main features
mephisto not developed anymore
radiant generic CMS
== Rails engines
refinerycms generic CMS
refinerycms-blog blog engine that integrates with refinerycms
blogit
ComfortableMexicanSofa generic CMS
comfy-blog blog engine that integrates with ComfortableMexicanSofa
Monologue: minimalistic blog engine with very few dependencies.
squeaky
hitchens
kublog
jabe
locomotivecms generic cms
BrowserCMS generic CMS
== Integrate jekyll with Rails
bloggy
If you're a fan of git, you might try Jekyll. It is a static site generator which allows you to do some templating. You don't need a database which makes running it on Heroku even easier.
It's been awhile since I looked into this, but I believe the two major Ruby blog applications are still Mephisto and Typo. They've both been around awhile and appear to still be maintained.
As Heroku has a read-only file system, you may need to do some tweaking to get them to work. Here's a blog post on getting Typo running on Heroku.
You may also want to take a look at Radiant, which is more of a traditional CMS system, but can be used for blogging. There's actually a tutorial on the Heroku blog about getting it up and running on their platform.
Finally, if you want something a bit more lightweight but with full CSS control you may want to take a look at Scanty. It might require you go get your hands dirty, but seems to run great on Heroku. In fact, it's written by one of the founders.
If you want a nice, hackable pure ruby & rack blog: RubySlippers
It used git to manage versioning of your posts and publishing as well. It is built to get a free blog going on heroku in record time!
~end shameless plug
I recently created a platform called Stipes.
It's based on Sinatra and it is very light in terms of required resources.
I installed it on a Raspberry PI recently, for internal, single-user, usage and it works very well. I'm still working on it and any support is welcomed.
If you are not into installing a fully fledged blogging engine, Bloggity may fit your needs, in fact you can use to add a blog to whatever app you may have.

Options for distribution of an offline Ruby on Rails application

I am developing an application in using Ruby on Rails, mostly as an excuse to learn the language.
This is not intended to be a web-based application - and perhaps I have chosen the wrong language, but...
My understanding is, that in order to run an instance of this application on somebody else's computer, they would need to install ruby on rails, and a webserver (or webrick, perhaps), as well as my application code.
I am just curious if there are any other options for distributing my application as a standalone app, or perhaps just a simple way to package up a web browser and ROR together with my app for a simple, one-step install?
I have personally never needed to do this. But, I have ran across this tutorial http://www.erikveen.dds.nl/distributingrubyapplications/rails.html that I think will be helpful. The tutorial covers how to actually convert a rails app into a standalone exe file.
Note, Slingshot appears to be a dead project (see comments). I'll leave this answer here for historical purposes and the off-chance that it comes back
Joyent's Slingshot might be a good bet.
Joyent Slingshot allows developers to deploy Rails applications like a standard desktop application, which work online and offline (with synchronization), have drag and drop, and interact with all the other desktop applications.
With Joyent Slingshot:
Create a hybrid Web/desktop application
Synchronize online and offline data
Use the same code for online and offline application(s)
Deploy and update your application easily
Drag into and out of application
Here are some further links to help with your evaluation and/or to help you get started:
Introducing Joyent Slingshot
Basic application walkthrough
Slingshot wiki
The way most people ship ruby programs, including Rails webapps, as a standalone exe is via rubyscript2exe. They describe how to package a Rails application at http://www.erikveen.dds.nl/distributingrubyapplications/rails.html. Ruby, Rails, and all the associated libraries will be included in the EXE file.
As others mentioned, Ruby is not necessarily Rails and if you really want an easy way to write a distributable GUI application in Ruby, Shoes is an excellent place to start looking.
Gears on Rails maybe?
You could always consider compiling your Ruby to JVM byte-code (via JRuby) or .NET byte-code (via IronRuby) to distribute to people who have those virtual machines and don't want to install a Ruby runtime.
You might want to check out Shoes for building desktop applications in Ruby. Rails really is tuned for building websites.
You can include Ruby on Rails by freezing it to the version of Rails you want to use in your project. They call this Freezing. The user will not have to install Rails to use your application. You can do this with any library you use in your project. If the project uses a library, just place it under the Vendor folder in your project. Then use a tool similar to what #Josh answered with to package it.
You will need a web server to run the project though. There is no way around this. Ruby on Rails is just like ASP.NET in this regard, in that it is a server side framework. The server runs the code and outputs the HTML to the browser by using the Rails framework.
Unfortunately, you may have picked the wrong framework to do what you want. Instead of Ruby on Rails, you may want to check out Shoes, which is a framework for developing GUI applications using Ruby.
You do not specifically say whether it is supposed to be a GUI application or not. From the other answers, I would guess so.
Therefore, you need to clarify what your goals are. RoR is a specialized framework for web applications. If your goal is to learn RoR, I'd say to get yourself some inexpensive web hosting and make yourself an app. If your goal is to learn Ruby, not necessarily Rails, then Shoes, IronRuby, JRuby, MacRuby and others may be good options to look at.

Resources