Developing Ruby and Rails in Windows? Or Linux VM - ruby-on-rails

I've been doing front end web work for a while. I maintain several company websites and etc, mostly on Joomla. I'm getting bored with it and I really want to expand in to development. I have a few web app ideas for the company and some personal stuff I'd like to do.
Ive decided I want to learn Ruby and Rails and have been pursuing it for about a month now. I read a lot of tutorials and work through stuff I find online. I'm also diving in to git and trying to use it more.
I feel like Windows is not going to be conducive to me getting efficient at this. I know that you can, and some do, develop in Windows but I'm wondering if its time for me to move past it.
I picked Ruby to be my first real programming language because of the simplicity I read about. For both Ruby and RoR and I want to be able to learn a language that will let me build apps and web apps that are cross platform.
On to the problem, I can't immerse myself completely in a linux world. I have to have photoshop and indesign for part of my job. So I'm thinking maybe I should just do a live usb key install and take it back and forth between work and home. Is that a better solution than dual booting for what I want to do? I also realize that a mac would give me the best of both worlds, but I am budget constrained and I can't make that leap yet.
Also, is there a good place to hang out to learn more? I have paid codeschool and tutsplus accounts. Should I be back on IRC? What do you think? I'm looking for guidance more than anything I guess. I feel kind of lost on where to go how to not waste time and start developing real skills. Thanks.

You should also checkout the vagrant project which creates headless (non-gui) VMs and makes it easier to work with your files, etc in Windows while the code actually gets run on the Vagrant VM. Also, since its headless, the graphical UI isn't eating up resources and has less impact on your host machine.
Check out these resources:
http://www.vagrantup.com/
http://blog.dcxn.com/2013/07/12/introduction-to-vagrant-for-rails-developers/
http://railscasts.com/episodes/292-virtual-machines-with-vagrant
*Also if you're learning Rails, you MUST checkout Railscasts http://railscasts.com/

The last thing I knew about this is that:
In Linux you can use RVM which handles pretty well everything about your Ruby environment. In Windows I tried pik, but it does not have support to install newer Rubies.
Also, Linux console is much friendlier than Windows one, regarding appearance and functionality. I have explored console2 for Windows, but it did not feel so comfortable that time.
In Linux you have plugins like oh-my-zsh which allows you to speed up your development. But maybe there are kind of this plugin for Windows.
Other than those, I don't know why you should choose Linux VM.

I've developed a Rails app under Windows, and it turned out to be a huge mistake. Near the end of the development, I had to make my webapp multithreaded. The default Rails server does not allow multithreading, and all the alternative servers are either Linux-only, or I couldn't get them to work.
I also considered using JRuby(because Java threads), but by then my app was too big to convert to JRuby(there are some syntax differences that I couldn't track, and I relayed on some gems that don't work on JRuby). However, if you go for JRuby from the beginning, you might be able to pull it off.

Related

Alternative to Windows and cloud for Ruby on Rails

I'm starting to learn Ruby on Rails and after a week I still cannot get the installation right. I've since moved to a cloud bases system, but it is extremely slow and rather a waste of time.
I do have a website and saw there's Ruby on Rails. Is it perhaps possible to set it up in a domain or sub domain and start and start learning/programming that way?
Any other alternatives is also welcome. I do now own a mac or Ubuntu, which makes it a little difficult.
Looking forward to your responses. In the meantime I'm installing/uninstalling and trying to see if I can somehow make it work on Windows.
Doing RoR development on Windows is a pain. I would suggest just uninstalling Windows and going for some Linux distribution if you are serious about learning RoR. Linux is free software so the only thing holding you back from having it on your computer is your self.
Developing with Ruby on Rails is say'd to be really easy for beginners but I would disagree with it. Developing on this framework requires you to actually understand the whole stack. The server, backend, client, database and ofcourse a new weird language called Ruby. Now most of this stuff is learnable and doable on every OS. But once you start messing with more advanced databases and servers, you will need some GNU utils from Linux.
For instance if you have made your first deployment to some external server, you will often need to know what is going on in there. The only way to do this is usually by going in that server with SSH and reading the logs. But doing that is difficult without a nice GUI. So now you have to learn some stuff like the tail and grep commands and Linux piping to find your info easily.
Also if the computer you use is not completely yours and you cannot do it on it, then try installing a virtual machine software like Virtual box.
With that you can install Ruby on a Linux that sits on your VM and use it like that. It will still be a bit slower but if your computer has decent hardware in it, you will still be happy with it.
Here is a guide on how you could do it: Guide for VM development

Setting up a Ruby development environment [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I am currently trying to set up a development environment for learning Ruby. The environment will primarily be for getting to grips with the language, but I will most probably move on to development with Rails after long. With web development a target, I would like to hear about preferred web servers and databases.
I plan on setting up the environment on a virtual machine, so I'm not worried about trashing the thing. Therefore, I am open to using a Linux distribution, OSX or Windows as the operating system.
I'm moving from C#, so I'd like to be forced into the Ruby way of thinking to a certain extent. Obviously, that's easier said than done.
What OS do most Ruby developers use?
What is the easiest IDE to get to
grips with coming from a background
of using Visual Studio?
Which
database is used most within the Ruby
community?
Which database is most
likely to be supported by most web
hosts?
Which web server is the
easiest to configure? To get up and
running in the shortest amount of
time.
Hopefully I have provided all the information needed and hopefully this will aid others in setting up their own environments.
Thanks
Edit:
Thanks guys. Some really good
suggestions so far, all of which I'll
take on board. I'm currently wading
through the copious articles surrounding
initial RoR setup on Linux, as I like to
understand how things work and are
tied together. Also, because it's all
free...
I'm currently putting together a
virtual machine (so I can break stuff)
using:
Ubuntu
SQLite
No webserver, I plan on using whatever development server comes with Rails out of the box, initially
Redcar Editor
Edit 2
I have setup a couple of environments
now.
I have the ubuntu setup running in a
Virtual Machine on Windows and decided
to try decking my Mac out for ruby
development too.
Overall, I'd have to say setup for the
mac was a lot less painful than the
linux setup. On the mac I'm running
with:
SQLite that comes with OSX out of the box(!)
TextMate (trial version, but loving it)
Mongrel web server
I've progressed from learning the ways
of Ruby to writing some simple
websites with Rails and am finding
development with Rails really simple
to use. I have also set up a GIT
repository on my working directory and
am currently trying out Heroku.
Thanks for the help, everyone.
If anyone would like any more information about setting up on either environment, I'd be happy to provide more detail.
What OS do most Ruby developers use?
Mac OS for most, but any Linux distro will do (Ubuntu/Fedora etc).
What is the easiest IDE to get to grips with coming from a background of using Visual Studio?
Textmate is quite popular if you're on Mac. Netbeans and Aptana are there if you need something similar to enterprise world. Emacs/Vim is ok too.
Which database is used most within the Ruby community?
So far most Ruby / RoR guys I know use open source databases. sqlite for local development while Mysql or Postgresql for production. My advice, sqlite is easy to learn, while give a try with Mysql or Postgresql, you might not know when your clients going to ask you to develop on them. Mysql is very popular. Postgresql I think has lot more features (personal preference).
Which database is most likely to be supported by most web hosts?
Mysql is most supported by shared hosting hence the M in LAMP (Linux/Apache/Mysql/Php). But Postgresql is getting more support too. Some hosting companies even support both but Rails developers usually prefer to use VPS (slicehost.com/linode.com) and manage all these themselves. Checkout heroku.com too for deploying your Rails app without needing much knowledge in sys admin stuffs.
Which web server is the easiest to configure? To get up and running in the shortest amount of time.
Developing with Rails you'll get webrick as a development server where you can test ur app locally. But for production I prefer modrails.com where you can choose between apache/nginx. I prefer to use apache since that is what I'm used to.
You'll want to look at RVM from the start, this takes away a lot of the pain of managing Ruby versions and gems.
Judging from the laptops I saw at Railsconf last June, Rails developers are about 90% OSX, 9.9% Linux, and there's like 1 or 2 guys on Windows.
Personally I use Textmate when I'm at home on OSX and gedit and redcar when I'm at work on Ubuntu Linux. I use sqlite for development mainly with mysql in production, but mongodb seems to be the new hotness, but I haven't done much more than some sample apps with it so I can learn it.
Virtual hosting providers will probably give you a choice of whatever database you want. Heroku is awesome and is used for deploying Rails applications via git, and uses postgres but has plugins to use mongodb if you want to go that way.
For what the community at large is doing, check out Thoughbot's survey results at: http://robots.thoughtbot.com/post/308239139/2009-ruby-survey-results
You might have a look at the Bitnami installer, which claims to create a full Ruby/Rails stack. There's also a VM version, so in theory you could just grab their VM and start coding your app. (YMMV -- personally I haven't tried it).
OS
Most ruby developers seem to gravitate towards Macs for some reason, with a few linux and some windows devs. That said, I use windows for all my ruby work and haven't really run into any huge roadblocks. Your safest option will probably be a Mac, if you want to be on the same side as most of the community.
IDE
You don't really need a full-blown IDE for ruby, as you would for something like C#. Most mac users seem to use textmate. I personally use redcar. It's not fully completed yet, but it can be used on Windows, Linux or Mac, and I've yet to run into a feature I need that isn't provided. It is written in ruby, can be extended through plugins, and supports textmate themes and snippets. To supplement redcar, I've actually written a shell in ruby for my own use. It's still in alpha stage, but I've got features like grep and ls working, and capabilities for working with and manipulating files. You can extend it with ruby, and actually use any ruby command inside the shell. It's hosted here, and is currently for use on windows. After I get some more features in, I might start looking at Mac or Linux ports.
Database
Open source options like sqlite and mysql are used widely. I don't have enough experience on them to really comment on the differences. For what it's worth, Heroku (which is great for hosting) uses Postgresql.
Server
You should use a lightweight server like Thin for development, to test your app. For production, have a look at modrails.com (as a few other answers have suggested).
Good luck with whatever you choose.
OS
80-20 Mac-Linux. I've seen one Windows ruby dev so far. If you use and debian (ubuntu is a debian), take a look at rvm, because debian cripples rubygems.
IDE
You can code ruby without an IDE, grab an editor of your choice. We've got emacs, vim, textmate, gedit here. If you really want an IDE, get rubymine.
Depends on how good your shell-fu is ;-)
DB
sqlite >:)
Server
For development, rails server should do. For production, my recommendation is unicorn, paired with nginx.
Further stuff:
http://github.com/edgecase/ruby_koans
And go for rails 3 beta.
Tutorials
ruby-lang.org/en/documentation/quickstart
Ruby community
ruby-lang.org/en/community/
I think Linux(Fedora) would be best for you
For data base mysql is very popular
most prefered web server
http://www.modrails.com/
http://github.com/fauna/mongrel
Ruby mine is good IDE
http://www.jetbrains.com/ruby/

Using rails or ASP.NET for website on Windows

I need to create a site that interact with some windows applications.
Currently this is done through direct calls so I would like these to run on the webserver.
This means that the site will have to run on a Windows based system.
I have been doing some ruby lately and am very keen on using rails for the site, but have at the same time seen plenty of discouraging posts regarding this.
Should I rather use ASP.NET (MVC) for a windows system or is rails stable enough to handle this?
Ruby on Rails on Windows is not ideal, but it does work, and works just fine for most purposes. The biggest issue you will likely run into is that the community of people running RoR on Windows is very small, so the issues you do run into which are specific to RoR+Windows may be harder to get help on.
If leveraging existing community is very important to you and/or your project, then I do recommend going with ASP.NET MVC. The community there is much larger and easier to connect with than RoR+Windows, which is fairly niche. Although it's difficult to put an objective value on the added benefit of having a community of support, it's clearly one of the biggest selling points for any platform - the RoR community in general, for example, is a huge part of its continuing success.
I would add to Rex's answer that RoR+Windows is fine for development, but i would not use that as a production setup. In my case i do a lot of work in Flash/Flex/Photoshop while working on the backend at the same time, and of course running those graphics heavy apps on Linux is not very ideal, but the server i deploy to is Linux which is the only part that really matters.

ruby development environment

is it better to develop ruby on rails in a) windows b) linux or c) mac. why ?
edited :
the reason why i am asking this is that i heard that developing ruby on rails in windows is not as stable/good compared when you used ruby on rails in mac. (not sure though if that is true or not).
plus the fact that David Heinemeier Hansson (creator of Ruby on Rails) seems to be using Mac, so initial impressions seems to be Ruby on Rails applications and Mac goes well together.
I strongly advise you don't develop on Windows. Why? First, there are a lot of things that break on Windows with every upgrade and the majority of gem or plugin creators don't use windows so they don't care about windows and don't run tests on it(there are several big name people who have flat out said that windows is NOT their problem it's yours). You'll find the *nix vs Windows problems will bite you in the ass again and again. Pathnames slashes, minor differences in ssh implementations, console and font problems, rubygems, capistrano, etc...
What will end up happening after a while is that you will always have this voice in the back of your head every time you have to debug something saying "Is this a problem only on Windows?" and that little voice is a cost to you..using up some of your battery every single day.
Macs are more expensive in terms of upfront dollars (which sadly I don't have) and linux platforms are more expensive terms of spending a day or two trying to get your wireless to work but those are upfront one time costs. The nagging insecurity of using Windows for Rails development is an ongoing cost. At least until the community starts rejecting things that are not truly cross platform.
As an example look at cucumber. For some reason a test framework is dependent on a particular console configuration not available in windows. So to use it in Windows you have to change the font in your console and change the code page in your console. Otherwise the letter "a" disappears from all the output. Why? Because it works fine for *nix systems and gives you pretty colours (I think this is a huge flaw and very very poor design choice even if you ignore windows).
You'll also feel like the guy who farted in the elevator every time you bring up a windows issue.
I say all this as some who has to use windows for his development platform at the moment. Hey, what's that smell?
[late edit: Ruby is also about 3 times slower on windows. This will impact your willingness run your tests all the time and hurt your TDD feedback cycle]
Shouldn't matter, whatever you're most comfortable with. I've done all three.
I suppose Windows is a little uncomfortable because of not being unix-based, the CLI is a bit more clunky.
(But if you use a tool like NetBeans, you don't really even need the CLI much)
I recommend against using windows when developing an app that will later be deployed on a linux system. If you're developing an app for practice, Windows is fine.
The issue is that if you're aiming at linux, then you'll want to have a full stack on your development machine: a web server, a dbms, perhaps memcached, etc. While it is possible to load all of that onto windows (I've done it), it will take longer than on a linux machine, will be slower and you'll have more difficulty finding assistance when something doesn't work.
Also, you can run into gem and plugin support issues on windows. Eg \ instead of / for directory paths and other weirdness. While rubyists will try to be helpful, windows support is sometimes limited since most RoR work is done on Mac or Linux machines.
Eg Capistrano has had problems running on Windows (they may be fixed now).
As an alternative, you can use Windows as your desktop machine, but use a linux machine as your development server for running the app. Any old pc will run linux just fine. Use samba to remotely access and edit the files from your windows machine. The linux machine does not need a display, you'll only use it remotely.
Just change your app's config/environments/development.rb to include
config.action_controller.consider_all_requests_local = true
so you can see stack traces from your browser running on your windows machine.
Regards,
Larry
Ruby on Rails works well on all platforms, but tool support varies. For instance, TextMate is a favorite editor amongst Rubyists, and it's Mac only. You'll be able to find lots of helpful tools for working with RoR in TextMate, so it might be best to do RoR development on a Mac.
I use Mac and Linux myself.
A Unix based system will offer you a path of lest resistance as all gems are available/compilable on these systems, which isn't as easy on a Windows machine. It's not impossible on Windows but you'll spend more time getting it to work rather in some cases rather than doing work.
Of those Unix systems my preferred is a Mac, it's got all the Unix power as well as all the interface niceties that can be lacking from your linux system, and of course I couldn't live without my daily dose of TextMate, so Mac it is.
I started life as a programmer in 1981 on early Unix systems. I stayed a pure Unix person through 1995. Then 'stuff' happened, (business ownership), and Windows came into my life.
So in 2007 I start learning RoR, pure Windows. I deployed on Joyent, which is Solaris. I've successfully developed two large apps, developed on Windows, and deployed on Solaris/Apache/Mongrel, without major incident.
The only Windows issue I ever remember is that I had to force filesystem reads and writes into binary mode to fix a 'development' vs. 'deployment' issue.
I honestly don't see any problem with developing on Windows and Deploying on Unix. But I had an extensive Unix background, I'm not sure the story would have been the same had I not know Unix.
Also, I'll only ever work on the RoR apps I build for my business. I'll never need to build any other RoR apps, I'll never develop any plugins, never have to take over another project, never have anyone INSIST I include something only available in something that doesn't work well with my Windows development environment, etc...
I'd say this:
If you are responsible for developing a Web app for your employer, and that employer is Windows based, that SHOULD NOT preclude you from considering RoR as platform. The app would have to be deployed by a third party, unless your employer is large enough and the project important enough to warrant in house Unix systems.
So if you know SQUAT about Unix, you MAY need a little help along the way. If you go with a third party Rails host, check out their support forums, make sure there are people willing and able to talk a non-Unix person through any deployment/setup and maintenance issues.
I'll give you an example, on Joyent, if I want to run a migration, I have to go through their Database GUI thingy, log into the database, then 'execute' a command. OK, so I get a simple text_field where I enter input destined for a Unix shell, which is:
cd /user/myhome/sites/mysite && rake db:migrate RAILS_ENV=production
That might not have been so easy to figure out had I not had the Unix background.
As of Ruby 1.9.2 and Rails 3.2, Windows is a lot slower for autotest and spork (one full cycle took ~15 seconds on average compared to mere seconds on Linux for the same project), but I enjoy better gui-centric git tools and functionality (TortoiseGit, WinSCP) among other things since I am much more familiar with Windows. I have verified that the essential features I need are working on both platforms, so I find breakage to be a lesser issue compared to speed.
Doesn't matter, If you're a purist then your dev environment should as closely match your production enviroment as possible with regard to Operating System and version of the Ruby and Rails. But really it doesn't matter much.
Some gems work on Mac but not some flavors of Linux (such as gitjour when I last tried it).
Using a Mac might be good or bad, depending on whether you want to know that whatever you develop will be able to work on any other OS.
I've done light rails development on both OSX and Linux (Ubuntu), and I found the differences to be almost imperceptible (in terms of ruby and rails... obviously the desktop environments are a lot different between the two OS's).
As others have said, most ruby/rails tutorials, gems, plugins, etc. are oriented toward Unix type systems, so I would assume there may be some annoying hiccups trying to do ruby/rails development in Windows, unless of course you're using IronRuby. :-)
A low hassle alternative for setting up a Unix environment for Rails development is to run one of the easier to use Linux distributions, like Ubuntu or Fedora under virtualization software like VMWare, VirtualBox, VirtualPC, etc.
I agree with many of the previous posts that Rails on Windows can be an issue. Its simply the case that many people developing for Rails are on Macs or Linux and as a result Windows bugs are not found, this is particularly an issue with plugins.
One issue with Rails is IDEs. TextMate on the Mac seems to be a popular choice, yet Linux and Windows options are pretty fragmented. Normally I wouldn't worry about this, but I have found that Rails becomes much more manageable when you have IDE support. In general there are lots of files located in a reasonably complex directory structure so having an IDE which allows you to easily find files your looking for is an awesome productivity boost.
Another thing you may want to consider is what your deployment environment looks like. For example, may people deploy there Rails apps on Linux servers. In that case, you may be able to skirt around bugs by developing on OS X, but unfortunately those bugs will crop up when you go to deploy your new software. That is the last place you want to be debugging code. Of course you should be testing your code in a staging environment first, but all too often people skip this step.
While searching for the answer to this question due to always having to hack my way around windows to things to work while developing in Ruby, I can say that if you have the option, use Linux or Mac. I've officially started using Ubuntu 9.04 as of today and here are the reasons why:
1) Can't do any ssh things like use Capistrano, vlad, create gems for rubyforge, etc. You can do these things using cygwin, but it's such a pain in the arse to use cygwin and windows working for everything.
2) The final straw was when trying to kick off background tasks in a rails app only to realize that windows can't fork processes.... didn't even bother with cygwin for this one, just switched to Ubuntu so I don't have to keep working around these issues.
Ubuntu 9.0.4 is pretty hot though, quite impressed so it may not be so bad.

Can you Distribute a Ruby on Rails Application without Source?

I'm wondering if it's possible to distribute a RoR app for production use without source code? I've seen this post on SO, but my situation is a little different. This would be an app administered by people with some clue, so I'm cool with still requiring an Apache/Mongrel/MySQL setup on the customer end. All I really want is for the source to be protected. Encoding seems a popular way to go for distributing PHP apps (eg: Helpspot).
I've found these potential solutions:
Zenobfuscate - not all types of Ruby code is supported however, so that counts that out
Ruby Encoder - may be the best option, as their PHP encoder looks alright (I haven't tried it however) but it's not available yet. I've used IONcube for PHP before and it worked well, but it doesn't seem that IONcube is interested yet.
Slingshot - it was mentioned in the other SO post, but it solves a different problem to mine and the source is still visible.
RubyScript2Exe - from the doco, it's not production ready, so that counts that out.
I've heard that potentially using JRuby and distributing bytecode might be a way to achieve this, but I've never used JRuby so I'm not sure what's involved.
Can anyone offer any ideas and/or known examples? Ideally I'd love to have some kind of automated build scenario as well.
Your best option right now is to use JRuby. A little bit of background: My company (BitRock) works with many proprietary and commercial open source vendors. We help them package their server software, which is typically based on PHP, Java or Ruby together with a web server or application server (Apache, Tomcat), the language runtime and a database (typically Postgres, MySQL) into a self-contained, easy to use installer. We have a large number of PHP-based customers (including HelpSpot, which you mention) but also several Rails-based ones. In the case of the RoR customers the norm is to use JRuby together with Tomcat or Glassfish although in some cases we also bundle a native Ruby interpreter to run specific scripts that rely on libraries not yet ported to JRuby (usually not core to the application). JRuby has matured quickly and in many cases it actually runs their code faster than regular Ruby. You will need to also consider that although porting your code to JRuby is fairly straightforward, you will need to invest some time on that. You may want to check JRuby Stack which is a free installer of everything you need to get started. Good luck!
If you release the source, obfuscated or otherwise, your app will be pirated. See, for example, Mint. It depends on what you're building, but you may find that you're better off releasing the app as a hybrid of sorts: A hosted app with a well-defined API, and a component that runs on the customer's server. As long as the true value of your product lives on the server side, you don't need to obfuscate your code, and you can just release the source code unmodified. Additionally, this may also give you the opportunity to reach clients running, say, PHP rather than Ruby. See, for example, Google Analytics, HopToad, Scout, etc, etc.
You can, but it wouldn't do anything to prevent somebody from reverse-engineering or modifying it. I remember there was an article about similar attempts to obfusticate Perl and how they could be effectively bypassed by a debugger and 5 minutes of effort.
If you can't wait for the delivery of RubyEncoder, then I think ZenObfuscate is the most promising. Though it may require some modifications to your source code, they do say this on their site:
ZenObfuscate costs $2500 for a site license or is individually negotiable for other licensing schemes. Yes, that is expensive. That was on purpose. But don't let that thwart you too much. If your product is really cool and we want to see it succeed, we'll make it work. "Really cool" is not freecell.
Of course, for $2500 (or more), you'd hope to get a few tweaks to the compiler that'd make your codebase fully supported. It might be worth engaging them in the conversation.
You can also take a look at Mingle from ThoughtWorks studios as an example of using JRuby for this.
It's a Ruby on Rails app, they run it using JRuby. They've customized jruby to load encrypted .rb files.
Take a look at JumpBox.
I've had conversations with them on the topic, and they seem to have a solution that will work soon for Rails apps.
I'm wondering if you could just "compile" the ruby code into an executable using something like RubyScript2Exe ?
To be honest I haven't used it but it seems like it could be what you want, even if it just packages up the scripts with the interpreter into a single executable.

Resources