Well built rails code for download - ruby-on-rails

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

Related

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

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.

How to create a project template for Ruby on Rails projects?

When I build Rails applications I find myself doing the same things over and over again. This includes adding the same gems/plugins, configuration info and custom initializers, rake tasks etc... etc....
This can't be a good thing.
So, is there a way to package all this repetitive code into some sort of project template ... so that I can do a "rails myapp" and have everything good to go from there?
Btw, running 2.3.5 if that matters :)
thanks
App templates is probably the feature you are looking for.
Many people just create the "template" and then commit it to a repository, possibly on GitHub, for easy access later. I personally find that this works really well.

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.

Good code sample in rails

I have been developing in rails for the past 1.5 years .. however , I feel my code is not upto the mark , and I still dont fully utilize all that Ruby and Rails have to offer .
I have gone through all the material that is available on the guide site , and have incorporated that in my code . However , every time I see someone else's code , I find out new things about the language like idiomatic syntax etc . I was wondering if there are some really good code samples of rails that people can refer which would help me speed up my progress in rails . It can be anything , like some open source plugin or a app that has really high code standards .
You can start from GitHub. There are tons of Rails plugins and apps available.
Here's just a few examples:
GemCutter
Spree
Fat Free CMS
Insoshi
Plugin authors
Thoughtbot
Ryan Bates
Bynarylogic
Joshua Peek
My favorite and commonly used gem/ Rails plugin is will_paginate. Pagination is pretty common in any web applications.
will_paginate is hosted on GitHub. It works as a standard gem.
If you want to learn about Rails plugin development including how to read the code, you might want to read Plugin Patterns in Rails 2.
Have a look at Mephisto, a blogging platform written in Rails: http://mephistoblog.com/

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