Deploying Rails as a desktop application - ruby-on-rails

I just start RoR development for two weeks, It's pretty amazing programming language so far. It's impressing me so much so that I'm start to thinking about change the programming language of my client's project from PHP to RoR. But what I want to know is, is it possible to make a RoR web app looks like a Native App when using it in a local machine. By the term of Native app I mean ..
The user doesn't have to run script/server or rails server every time they starts their machine
Either access it by Web Browser or something else is fine.
Can be running with Window 7 or Window XP
Other recommendation are welcome. (Including, the reason not to use RoR to develop a local application)

I personally don't think there's anything ridiculous with wanting to deploy a Rails app as a desktop application but it's certainly not the easiest thing to do. Heres a list of what you're going to need:
a compiled distributable ruby interpreter
a distributable database
a script to bootstrap the whole thing( preferably that runs on the click of an icon or when system starts)
an installer
optionally:
write a simple shell in qt or java(possibly with the ruby bindings even) that handled starting and stopping the rails app, and provided a webframe for your customer to use instead of the standard web browser.
Here's a tutorial on deploying a rails app as a desktop app, though for debian, that should start you in the right direction. But your best bet for a quick gui application in ruby is shoes.

since rails is framework for web development there is no way to avoid starting rails server to show something on local machine. you might hide the fact that server is being started by running it as service without letting the user know about it but that's only as far as you can get.
so yes, it is possible to bundle your application into a "native app" but i'm afraid it will be extremely fragile as there are too many pieces that need to fit together: ruby itself, database to use, rails and all the other gems. big chance is you will have a gem that needs to be compiled and then you're in trouble.
bottom line: it's not worth it, either host your app or pick a better solution to develop something that runs only locally.

Maybe out of topic, but if you want to make native application, perhaps make native application? I mean, what's the purpose to develop a web application and then host it locally?
At least, you could consider using free hosts, such as heroku. http://your-project-name.heroku.com will grant you a 5mb database and 1 worker. It's free, will save you a lot of troubles and will make it easier for you to deploy newer version to your clients.
Just have them put a bookmark on their desktop if they want to double click to open application.

Maybe I am wrong but you seem to miss the fact that RoR is not a programming language. Ruby is a programming language and RoR is web-development framework. Anyway if you want to develop desktop applications, you can use Ruby with a framework such as Bowline (to keep the MVC spirit).

If you want a Web application, build a Web application. If you want to build a desktop application, try Monkeybars or Appcelerator.

Quite late for my answer but anyway I had the same problem and use the gem ocra to build an exe for windows.
It is also possible to generate a setup to install the program in the register.
It is still necessary to have a server started but the user has just to click on the exe program; A console is opened and give some instructions like 'after the start of the server, open a browser and go to localhost:3000; Ctrl + C to exit when you have finished.
It could be possible to have the server launched as a service but I think my users prefer to know if the program is running or not.
ocra is not really easy to set but eventually it works fine.

Related

Deploy ruby on rails on FTP

Is it possible to deploy Ruby on Rails app on FTP?
If possible then how run migration on it?
My app also have a cronjob. How to set it?
How I deploy my webiste on FTP?
If any tutorial etc availble?
Technically it is possible to deploy by FTP, but the question is, why would you want to? It's a nightmare when compared to a modern, automated deployment system. There's also serious security concerns since FTP is not in any way encrypted and is extremely easy to crack into. Using public Wi-Fi exposes you to the risk of your credentials being captured.
The traditional way to deploy a Rails application is with Capistrano which handles packaging up your application through your version control system and rolling it on to your production system.
If you're not using a version control system that's the first thing you need to fix. Hacking away on files randomly and throwing them to a server over FTP produces quick results but over time it makes it very difficult to get a consistent, tested, reliable build over to your target server.
Remember that Rails is not something that runs automatically like .php files can be, you'll need to use something like Passenger to handle launching your application.
If all this seems a bit convoluted, it's worth trying Heroku to get started. They have a very streamlined approach.
If I understand right what you are asking (is it possible to run Ruby program using only FTP as a protocol), the answer is no, it is not possible. Ruby files is not Web static content (HTML, JS, CSS) that is executed in a browser and hence you can just upload it somewhere (as an option using FTP) and then access via Web. In case of Ruby, apart from uploading content you need to execute commands there (start interpreter, rake etc.) and this is not possible to do using plain FTP.
Normally you may want to use SSH channel to the deployment server to run the program after it has been uploaded. In that case upload is possible via FTP, but as well secure version of it, SFTP (or SCP to just copy files between local and remote machines).
Hope it helps.

How to distribute ruby on rails offline applications?

I was following the solution on this answer for distributing rails apps but it seems like it's not up to date for everything with slingshot.
I just can't get it working. Is there a new or another way to get a rails application distributed into offline exe file and .app for Mac OS X ?
I went down this path a year or two ago and didn't find any success. I couldn't ever get Slingshot to work with 2.3.x Rails apps, I even thought about deploying the application on an entire OS system wrapped up into a virtual .exe using Xenocode (which is now Spoon Studio). Ultimately, I rebuilt the back-end Ruby stuff in javascript and deployed it as an AIR app, not something I'd recommend or even do again myself.
There's another thread on this topic with some other options listed in the answers and comments:
Distributing Rails Applications as Native Applications
Good luck.

Is there a way for a ruby on rails app to support web-based upgrades like Wordpress does?

I've been using Wordpress for awhile, it's installed on my own server, and one of the features I most love about it is how every time there is a new version it alerts you within the app's web-based admin and with one click I can upgrade the app. I don't have to get anywhere near a console.
Personally I wouldn't mind updating manually, but I can see how this could significantly affect the adoption of a piece of software. I'm working on creating a full-featured ruby on rails forum software and I would love to figure out how to include this feature. Any ideas if this could be done with rails?
Could a rails app modify it's own files? If it did, would the server need to be restarted?
To complicate things further, what if the app was deployed from a repo. Could the rails app check in a commit of itself after updating?
Maybe packaging the core of the app as a gem would be simpler? Then maybe the upgrade would not actually modify the rails MVC stack (the rails app would just be super-basic), instead if the forum was all contained within a gem then all it has to do is trigger a 'gem update [name]'. If this occurred, I don't think the Gemfile would even need to be updated. Would a server restart even be required to load the updated gem?
Ideas or feedback on any of this?
Rails files can be modified and even deleted on production - in my case aplication is still working unchanged as all classes are cached in memory. It means Rails instances must be restarted to take new change.
I suppose WordPress is Perl via CGI and you just drop application into web directory to have it working immediately - same with updates - just overwrite files and Apache picks them up immediately.
In case of Rails is that you don't know target deployment architecture thus restarting application may not be trivial. E.g. with passenger I can just do touch tmp\restart.txt and then all instances are killed and started again. Some deployments may need init.d script restart invocation.
Maybe you could recommend or prepare a ready to use deployment model which supports autoupdate. In other cases users could do updates manually.

Distributing Rails Applications as Native Applications

I would like to distribute a rails application as a double clickable application. When someone double clicks on the app, I think that mongrel should be started and then the user's browser should be started and open to something like localhost:3000 I'm trying to work through what I will need to do this, I think I'm going to need to include a copy of rails in the project, and a copy of the gems. Do I need to distribute ruby? Initially I'm looking to target the mac and linux for distribution. Does anyone have any experience packaging rails application like this?
The Application I'd like deploy is a media center server for a user's media. Unfortunately this means I can't have a public server serving out the media. I've built up the server using ruby on rails and rake tasks to import and manage the media. Is there a good way to make this easy for users to install? The idea was with a double clickable application it would be easy for users to bring up and down the server.
I've decided to use jruby and look into packaging the application as a java app.
The ill-fated Joyent Slingshot did exactly that, it allowed you to embed your Rails application as a standalone executable under Windows and Mac. It even provided a simple but straightforward method to allow data synchronization with an online version. Alas, it hasn't seen any activity in a long time.
https://dev.joyent.com/projects/slingshot/wiki/Slingshot
Spiceworks is a desktop-deployed Rails app, or at least it was a couple of years ago. It's a free (ad-supported) download.
Appcelerator Titanium natively supports building client-based/desktop applications using Ruby.
Hey, take a look at shopify and their theme designer app. http://vision.shopify.com/
Is pretty much exactly what your talking about. All they have done is written a stub for both platforms that launches the rails project. You can take a look at the code that checks for the rails project browsing through the vision app package contents.
I agree with the previous posters regarding desktop apps but I find myself writing web apps for the desktop (mostly widgets using Fluid) so I understand the issue. Has anyone had a look at Titanium Desktop from Appcelerator (http://www.appcelerator.com/)? I tried it initially and there was a little fiddling required, but the end result was more or less a desktop app.
If you want to write desktop apps, write desktop apps, if you want to write web apps, write web apps.
In the future, I think MacRuby will provide an excellent way to run web-apps on the desktop (well I mean OS X desktop) - you could in theory, spin up a Rails app and then have a WebView point to the Rails app. Currently, they're still focusing on making MacRuby a first-class citizen of the OS X ecosystem but Rails support is on the roadmap.
MacRuby is also exciting because of the work on the AOT compiler, with which you can compile Ruby code to machine code.

Windows Rails-IDE with Remote-File-Support (FTP/sFTP)

I am currently using Aptana RadRails for Ruby on Rails development on my local system.
Now I want to work on a Rails-Application that is hosted on my dedicated server, but unfortunatly RadRails does not provide support for Remote File Access (apart from SVN).
Is there an IDE for Rails-Applications that gives me the ability to work on an application on my remote server transparently?
Is this what you're looking for?
You're doing it wrong!
Seriously, you should be using source control and you should be releasing your software with a deployment tool like vlad or capistrano.
You run your app locally, commit changes, then run deploys to your server. Once things are setup you shouldn't need to even log in to your server.
Developing the way you're doing is going to cause many headaches and reduce your productivity. Now the snide rails developer comment, if you really cared about productivity you wouldn't be using windows in the first place...
It's not available yet, but Haven will allow you to edit files via FTP/SFTP in your browser. It will also allow you to plug into your source control if that's where your stuff is. It should be a nice alternative to the current fat client options.
Disclaimer: I'm a co-founder of Wikid Labs.

Resources