What components make VIM a good (great) ruby editor? - ruby-on-rails

I'm learning ruby on rails on a linux box and dusting off my VIM skills (skillz?).
When I got started on VIM way back in my c++ days, I had a friend with a great vimfiles folder that had tons of stuff to get started. Starting from scratch, vim is great, but it feels like it could be a lot better.
I currently have:
vim-ruby
buffer explorer
xml-edit (though I don't have it currently working with erb files)
I know that barely scratches the surface of what some more experienced vim/ruby devs have (including the one offs in the vim.rc file).
Is there a list somewhere (or could we create one) of a bunch of the standard vim configurations needed to make programming ruby (and rails) more fun? Is there a zip/tarball somewhere with a good base setup?

take a look at tim pope's repos on git hub. Many, many awesome vim plugins and extensions for working with ruby and rails
http://github.com/tpope

snipMate (GitHub repo) is highly recommended. It enables you to use TextMate-style snippets in Vim.
snipMate is not Ruby-specific: by default, it comes with one file containing Ruby-specific snippets. If you are going to work a lot on Ruby-based code (Rails, RSpec, Shoulda, and the like), it's probably better to use one of the available snippets' collections and customize it as you see fit rather than writing your own snippets from scratch.

There is a pretty nice setup for your VIM environment.
http://github.com/akitaonrails/vimfiles
Just follow the instructions and in a minute or two you will have everything ready for Ruby(on Rails) development.
As Jed has mentioned above - tpope plugin is a "must have" and it is part of the akita vimfiles.

I have this in my ~/.vimrc to quickly see the output of a file I'm working on:
map <Leader>r :w! <bar> !ruby %<CR>
For rails, two essential plugins are rails.vim and the NERD tree, for navigating the directory of the rails project you're working on.

Related

Well built rails code for download

I want to get into rails by examining well built code
where can i find typical open source rails project that i can download
and learn from ?
i'm interested in facebook connect integration (facebooker), tag clouds, searching in
my website
I'm not looking not tutorials or screen casts
Thanks!
This question gives a good list
a list of projects with good test-suites
a list of open source rails apps to learn from
Have a browse of ruby tool box and download some open source. For example there's refinery and zena, two content management systems and Rboard, a forum. Depends what you want really but there's plenty out there. Ruby toolbox entries are ordered by github watchers and forks to give you an idea of their popularity.
I really like looking at the commits in teambox.
I find it a bit more complicated. But there's also spree.
There's also devise which is really interesting to look at too.
Finally, I'd recommend you to follow the rails commits (it's the only commits feed I have in my Google Reader).
Gady, this is an extremely rich topic you're asking about and resources are all over the internet. Try starting at http://rubyonrails.org/.
You should be able to find tens of questions just like yours (asked and answered) by searching SO at the top bar.
For Rails, part of it is the building process, so one feasible approach is to read a tutorial like http://railstutorial.org/book
then when in Chapter 2, you will use Scaffold, and at that time, you will have some basic code to look into how a basic Rails app is.
I also suggest you use source control like Git, Mercurial, or SVN to commit different phases of the project, from creating the rails project and then after each step, so you can diff what the changes are during each step.
If you already have Ruby 1.9.2, Rails 3.0.1, and sqlite3, then you can
rails new myproj
cd myproj
rails generate scaffold foo name:string salary:integer gpa:float note:text
rake db:migrate
rails server
and now you can use http://localhost:3000/foos to create, display, update, delete the foo records, and have quite a bit of source code to look at. Most of the customizable code is in app, with css and javascript in the public folder.
Ryan Bates has an excellent series of videos.
http://railscasts.com/
An extremely valuable resource.
Radiant is a CMS that you can download for free and see how it works. It is a great piece of code to look at and see how it works.
I guess that most open source Rails projects are shared on Github, so it may be interesting to browse its Ruby section and look for most watched or most forked projects:
http://github.com/languages/Ruby
Steady stream of new interesting projects to take a look at :)
And don't forget the official:
guides.rubyonrails.org
well there is one "bigger" project on github, waiting for downloading and contribution...
but it's a little controversial because of the security issued they have (had?)
It's still worth a look:
http://github.com/diaspora/diaspora

Compiling / building ruby online from a working rails application

I'm totally new to Ruby but not to programming. All I did was going through try ruby and reading differences from other few languages I know better (mostly PHP and some Python). So I have no idea how Rails differ from Ruby and maybe this is an absurd question.
Anyways...
I don't want (or am able) to install Ruby on my machine and I'd still like to build a single working source file. Is it possible to have an online compiler of some sort? If so, how?
If I write a Rails web site (comprised of either one or many files) using any given host (that far I know I can), would I be able to use that same code with very minor modifications and just run as a Ruby app? Again, how?
(new) What about the other way around: a Ruby app turning into a Rails web page? Easy to do?
I really hope for a "yes" on them all, but I doubt on the 1st and not so much on the last. :)
There are online "IDEs" you can use to try out ruby:
http://ideone.com
http://codepad.org
But mind you that Ruby on Rails is a framework written in Ruby and those sites don't have RoR installed. Also note you that a Rails app has many, many files.
If you have the same code and same server configuration (version of ruby, database, plugins, etc.) you should only need minor modifications to the config file.
Ruby on Rails is on Ruby. So whatever works on Ruby should work just fine on RoR with minor modifications. However, you'll probably want to rewrite the app to take advantage of many of the features RoR provides.

tips and tricks for using vim with ruby/ruby on rails

I'm one of those developers who isn't using TextMate with any of his Ruby/Ruby on Rails work. My particular loyalty in this arena lies with vim. What are your favorite tips/tricks for using vim with Ruby and/or Ruby on Rails to make you as efficient as possible when working?
Most important
Get a copy of rails.vim it is awesome on millions of levels. Read the doc. There are way too many tips, :Rview customer, :RSmodel foo, :Rinvert, gf, :Rextract, :Rake and the list goes on and on. You will probably want NERDTree as well for easy navigation (which you can access using :Rtree)
Second most important
Follow tpope on twitter (the author of fugative, rails.vim, haml.vim, vividchalk theme, cucumber.vim and so on), he seems to be posting new related to Rails vim plugins quite regularly (be it syntax highlighting or git integration).
You might want to checkout my ruby/rails specific vimfiles.
Its a useful starting point and has many useful Ruby/Rails plugins bundled and configured.
The one thing that really sucks about Textmate is that it doesn't run on Linux. My vim/gvim config is the same on Mac, Windows and Linux. Same fonts, same themes, same plugins and same customizations.
I mostly use Textmate for snippets and quick evaluations for posting here.
I wrote an in depth guide on using Textmate features (especially Rails related features) in VIM. It's very relevant to this question.
http://www.jackkinsella.ie/2011/09/05/textmate-to-vim.html
I don't use vim, instead, I'm like those millions of developers using Textmate. Nevertheless, a colleague does use vim/gvim.
By looking at him work, one of the things I wish I could do in Textmate is the ease of working on multiple files at the same time. Basically, you can easily manipulate multiple windows, which is quite handy.

RoR development-environment setup

I'm interested to play around with RoR a bit. Apart from literature i should read, i'm particularly interested about how to setup development environment.
Here's a good example how to setup environment for Java from Noda Time project wiki pages.
I want something similar but for RoR.
As far as i know - unix operation systems fits way much better (have toyed on windows 1 1/2 year ago - pure nightmare). So it would be nice to get some recommendations about linux distros and how to make it run next to win7/xp.
Basically - i want to shorten endless searching and improvisation until i can play with some code.
P.s. bonus for simple sample project. :)
The single quickest way to get up and running might be to simply grab Netbeans and develop against its built-in JRuby instance. It will walk you through setting up a Rails project and even give you some nice-to-haves like autocompletion.
Baring that, the easiest method is likely to download a Linux VM Appliance pre-Customized for Rails Development and a copy of VMWare Player.
The best 2 ways to go are OS X and Linux, I use Ubuntu just because it's the nicest package that I've found (there will no doubt be a variety of opinons on this.)
For Rails, I like to not use the packages or pre-installed versions, and instead build my own so I can test against various versions of ruby if need be. Hivelogic has a nice post about how to do it for OS X 10.6.
From there, you can just run:
rails myproject
cd myproject
./script/generate scaffold post title:string body:text
rake db:migrate
rm public/index.html
./script/server --debugging
And then connect to http://localhost:3000/posts to get to your application.
Once you get more comfortable, check out running Passenger instead, so you can have multiple applications running at the same time. On OSX there's even a nice Prefpane to easily set up new sites. This also ins't too hard in Ubuntu with the examples provided in the passenger docs.
For editing the application I think the IDEs (Aptana, Netbeans, etc.) are still too heavyweight, especially for small starter projects. I like Textmate (like everyone else) for OSX and gedit with gedit-mate.
Once you're writing applications, you'll find that railsapi has the best interface for browsing all of the various methods not only in Rails, but ruby, authlogic, and a bunch of other common gems.
Lastly, you'll want to look into source control, with git being preferred in the Rails community at the moment.
Good luck!
Get VMWare player
Get ubuntu vm
If it's server version - install desktop x or whatever it's called
Mess around with sudos, visudos
Mess around with vi editor to save newly created account to sudoers list
Mess around with vertical mouse scrolling which apparently does not
work on vmware+ubuntu
Finally install netbeans
Through plugins, install ruby on rails
Some global updating
Enjoy toying
tadaaaa...
Something like that i wanted - with each point explained a bit (no doubt that my steps aren't best ones and sounds funny for those who knows).
I guess that i forgot to mention that i lack knowledge of unix systems in general too.
Anyway - got what i was looking for. :)

Coming back to Rails

So I've decided after a few years away, that I want to get back into Ruby on Rails for some of my personal projects. What I'm wondering is what are the best resources to find out what the new features are in rails? I haven't really even touched Rails since 1.2 was new.
Oh yeah, and is TextMate still the defacto editor for RoR on the Mac, or has something better come along?
Check out the official Rails Guides. These should provide a nice overview of Rails (if you are rusty) and are kept up-to-date with the latest versions.
You may want to check out Ryan Daigle's Edge Rails posts which covered features as they were added to the new versions. Use the dates to determine where to start and go through each one. He also has a PDF for $9 which covers upgrading to Rails 2.1.
I have also covered the changes on Railscasts. Check out the various tags for each version to see them: 2.0, 2.1, 2.2, 2.3.
Update: Thoughtbot blog has posted about upgrading to Rails 2.1 and 2.3.2.
I found the book Agile Web Development With Rails (3rd edition) to be the most helpful to get me going again earlier this year. In particular it notes some concepts that have changed as well as introducing the new items.
Regarding editing, Textmate still seems to be #1 among the MacRails folks, the text-editing ones, at least.
Beyond that, there are some IDEs around now, if that's your preference. They're starting to become fairly not-awful, which is pretty impressive really. There are plenty of questions here that touch on the topic: try searching for "ruby rails ide"
The Ruby Toolbox is a great and fairly new resource for seeing what gems/plugins/tools are popular for various aspects of your application such as authentication, testing frameworks, search, etc. It's based on the number of watchers and forks each project has on GitHub, which is a reasonably good way of judging popularity.
As for a newer editor ...
I have found that sublime text is a great editor for ruby and rails projects, it has great syntax highlighting out of the box, Vim keybindings available (vintage mode), a sweet package system to add functionality for other languages like SASS or Coffeescript and an excellent file browser that helps with complex folder structure that can happen in a rails project.
Also, it is highly extendible and configurable, I switched to it from Vim.
http://www.sublimetext.com/

Resources