How to distribute ruby on rails offline applications? - ruby-on-rails

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.

Related

Ruby on Rails: is there an ideal app directory structure in Windows

Just a quick question from a Rails learner.
As I understand it, it is not necessary to place a new Rails app inside the directory where Ruby and Rails are installed.
But, is there an ideal place for apps? What are experienced developers using?
I ask this, because I may have misplaced a previous app, hidden somewhere deep in a directory structure; and, strange as it might seem to most of you, I cannot find where the older app is.
I have quite some problems searching in Windows 10; it is a nightmare, compared to how it was in Windows XP.
There isn't "standard", community agreed directory structure for Rails apps.
However, I noticed that many developers would create Projects folder within their "user home" directory (C:\Users\username in Windows and ~ in linux distro). I do the same and when I need to find some project I worked on 5 years ago, I don't think twice where to look for it. Obviously, that means you'd end up with a lot of project dirs in your Projects folder. So I move very old projects to my backup disk occasionally.
A quick note on Ruby/Rails. Rails projects are not like PHP. They are more like Java, when you run your application (as a separate process) and it stays in the memory running & serving user requests. In PHP you had to put your php files into your server's document directory so that server could parse and execute your scripts. So, with Rails projects you are not limited with where you put them.

Deploying Rails as a desktop application

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.

How can I run a Rails 1.2.5 application on ruby 1.9?

I have a old app made on rails 1.2.5, this application have alot of access per day.
I intend to upgrade my server (a joyent accelerator) to run ruby 1.9.x and work with rails 3 but I can't stop or move this app to another server.
Have any way to run this application on ruby 1.9?
or run two ruby versions (1.8.7 and 1.9) at the same time?
or on the last case upgrade my app to work with rails 3?
Thanks.
There was quite a few patches to Rails to make it run under Ruby 1.9. I think you are up for a challenge if you try to do that. With Ruby Version Manager you can work with multiple ruby environments from interpreters to sets of gems.
Does it have to be switched over to Rails3 and Ruby 1.9?
Can you just throw you old app on a virtualized server and keep the app running as is?
The reason for my suggestion is that we just went through a similar case. A local business (a construction association) had a pair of apps developed for them 2-3 years ago (works with Rails 1.2.6). Nothing overly major (a billing app, and a bid/contractor/customer management system). Everything works, so no need to update anything.
Their hosting provider was not willing to keep an old outdated rails available in shared hosting environment. Hosting shop cited maintenance can't be streamlined, security concerns, etc. Sure enough, the same host offers to rewrite the apps for current technologies (for a price, of course).
Client wasn't happy with them. The shop that developed the apps since closed and the developers left for greener pastures. But everything works, so why reinvent the wheel, right? Client went looking for alternatives. Came to us. We sat down with the client, did some cost/benefit analysis and decided to just host in a virtualized environment (at another provider). Did that in a week (with some hick-ups): back-up, move, restore, test, everything works. And it's been working now for 3 months without any issues.
This might not work for you, but unless you need to add to the app why fix what ain't broken?
Rails 3 works with Ruby 1.8.7
Another option (apart from obvious RVM) is to leave your Ruby 1.8.7 and Rails 1.x as is and install latest JRuby and Rails 3.0 and dependent gems with jruby -S gem install rails. Ruby and JRuby gems perfectly coexist without any interference. OpenSolaris in Joyent's Accelerator is good at running Java, so you won't have much problems with it.
P.S. Btw, I won't recommend updating your Rails 1.x app to 3.x, unless you're planning to add lots of new features to it. It can be very painful, especially if you used lots of old-school gems and plugins.

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.

Locomotive slowing to a crawl

I have recently been building very small and simple apps using Locomotive 2.0.8. Until now it has been the ideal solution, but recently the application has slowed to absolute crawl. It takes literally 10 minutes to boot up, 5 minutes to add an existing or new project - and often these creations don't even work correctly. I can't imagine what I have done. I have tried uninstalling Locomotive, and clearing my directories. What could be causing this? Something to do with RubyGems? any other solutions besides Locomotive? Or how can I completely uninstall Loco, gems, and all my projects and essentially format my dev environment to start anew?
Locomotive isn't really necessary anymore. You used to be a pain to get a decent ruby environment running on os x, but these days it's easy. Google for 'compiling ruby mac os x'
Another solution to getting your rails apps running is to use Pow to serve it and then use Anvil to control Pow.
Bam!

Resources