#113
Jun 09, 2008

Contributing to Rails with Git

If you want Rails to behave a certain way, try changing it and submitting a patch. This episode will show how to do exactly this using Git.
Download (45.5 MB, 11:36)
alternative download for iPod & Apple TV (21.5 MB, 11:36)

Resources

# run tests
rake test
cd activerecord
rake test_mysql
rake test_mysql TEST='test/cases/named_scope_test.rb

# make changes on branch
git checkout -b named_scope_with_bang
git commit -a -m "named_scope with bang"

# pull recent changes and apply to branch
git checkout master
git pull
git checkout named_scope_with_bang
git rebase master

# make patch
git format-patch master --stdout > ~/named_scope_with_bang.diff

# apply patch
curl ... | git am
create database activerecord_unittest;
create database activerecord_unittest2;
grant all on activerecord_unittest.* TO rails@localhost;
grant all on activerecord_unittest2.* TO rails@localhost;

RSS Feed for Episode Comments 66 comments

1. Russ Jones Jun 09, 2008 at 01:57

Awesome topic, thanks Ryan :)


2. Senthil Nayagam Jun 09, 2008 at 18:36

Now people wont one less excuse for not contributing back to rails :)


3. Tom Harrison Jun 10, 2008 at 12:05

Very cool, Ryan. You sure covered a lot of territory here ... kind of like one of those cooking shows where all the vegetables and ingredients are prepared in advance, and the food has already baked in advance :-)

So this gets to the core of the main steps of making a contribution. For the more timid amongst us, do you have any pointers on some of the "pre-show" work that should go into making a patch?

For example, you mentioned in passing that it was a good idea to make sure the functionality wasn't already implemented. Now being about 9 months into RoR I am still learning a lot of things I just didn't know existed. Any tips on knowing what a good candidate is for a patch?

Thanks for all you do.

Tom


4. Mike Jun 12, 2008 at 06:39

Nice walk through on contributing. With the patch you wrote couldn't you have re-written your method as:

def find_products
 returning Product.scoped({}) do |conditions|
  conditions! ...
  conditions! ...
  conditions! ...
  conditions! ...
 end
end


5. Ryan Bates Jun 14, 2008 at 14:01

@Tom, excellent questions. As mentioned at the end of the episode, I think subscribing to the Rails Core google group is the best way to get started. Keep up with the tickets coming in, try them out, and give feedback. Sometimes there will be tickets which don't have a patch, or just include a failing test. These you can try contributing a patch to.

As for coming up with patches from scratch, that's kind of hard to do on the spot. The best thing to do is to work on a Rails application and look for possible patches that will aid your app. This will lead to patches which have a real world use case and will more likely be useful to others.

As for your second question, I've ran into that a number of times, where I thought of making a patch for something and, after a little digging, realized it was already implemented in Rails.

Usually you can tell if it's already implemented by reading the Rails source code. If you don't see it, go ahead and submit a patch and others will point you to the existing functionality if it's already implemented. If it's a larger patch, it's probably best to ask in the google group before attempting to implement it, to see if others would find it useful and if they have any ideas on the implementation.

@Mike, you would still need to call "conditions!" on a scope object. In your code it's just being called on "self" which is the search model.


6. Rick DeNatale Jun 23, 2008 at 10:03

Ryan,

I always add a step right after the git pull followed by rebasing my branch, and that is to rerun the tests to make sure that they still work should any changes pulled down affect them.


7. Tim Haines Jul 01, 2008 at 15:04

Hey Ryan,

thanks for this screencast. I installed git and followed your screencast to submitted a patch - only to find later that my changes to files were in the patch, but the new file I had created wasn't included. I spent a bit of time this morning trying to figure out how to get that file included in the patch, but haven't had much luck yet. Is there a good resource for learning this stuff somewhere? A walk through for first timers?

cheers, Loving your work as always.

Tim.


8. jamir Jul 06, 2008 at 03:15

Thanks a lot for the patch!


9. Cassiano Sep 21, 2008 at 20:41

@Ryan,

You seem to have mispelled 'activerecord_unittest2' in the code that appears at the top of this page (just below 'Resources'), so:

create database activerecord_unittes2;

should actually read:

create database activerecord_unittest2;

Also, I believe you missed the -b flag in:

git checkout named_scope_with_bang

so it should read:

git checkout -b named_scope_with_bang


10. Ryan Bates Sep 27, 2008 at 13:30

@Cassiano, Thanks for pointing these problems out! Fixed.


11. Mike Perz Jul 26, 2009 at 17:43

Ryan, Thank you. I didn't have the mocha gem installed. Got a lot of "NoMethodError: undefined method `expects'/`stubs' for ...". But once I installed it, all the tests passed. - Mike


12. shoesghost.com Nov 11, 2009 at 04:16

welcome to
www.shoesghost.com
cheap boots and shoes


13. estetik Dec 15, 2009 at 23:54

Nice post good article to read.


14. Evdokiyushka Dec 26, 2009 at 14:39

As for your second question, I've ran into that a number of times, where I thought of making a patch for something and, after a little digging, realized it was already implemented in Rails.
[url=http://sevenportal.ru/]Evdokiyushka[/url]


15. kablo Jan 07, 2010 at 01:50

kablo üretiminde lider kuruluş


16. kurye Jan 18, 2010 at 06:25

Ryan, Thank you. I didn't have the mocha gem installed. Got a lot of "NoMethodError: undefined method `expects'/`stubs' for ...". But once I installed it, all the tests passed. - Mike
 my web page <a href="http://www.jwebtasarim.com" >web tasarım</a>


17. Svetuha Jan 19, 2010 at 23:59

The best thing to do is to work on a Rails application and look for possible patches that will aid your app.


18. hemoroid Jan 22, 2010 at 16:32

thank you very much


19. Web Tasarım Jan 26, 2010 at 00:45

A very good article, I will always come in.


20. Ksenyusha Jan 28, 2010 at 12:31

For example, you mentioned in passing that it was a good idea to make sure the functionality wasn't already implemented. Now being about 9 months into RoR I am still learning a lot of things I just didn't know existed.


21. Danusya Jan 30, 2010 at 23:43

Now being about 9 months into RoR I am still learning a lot of things I just didn't know existed.


22. Emunya Feb 17, 2010 at 03:36

If you don't see it, go ahead and submit a patch and others will point you to the existing functionality if it's already implemented. If it's a larger patch, it's probably best to ask in the google group before attempting to implement it, to see if others would find it useful and if they have any ideas on the implementation.


23. Vita Feb 18, 2010 at 11:08

Нечего не понятно


24. özel güvenlik şirketleri Mar 02, 2010 at 11:02

thank you for post


25. ariston beylikdüzü servisi Mar 03, 2010 at 13:37

thank you for shared <a title="büyükçekmece arçelik servisi" href="http://buyukcekmecearcelikservisi.com">büyükçekmece arçelik servisi</a> and
<a title="büyükçekmece beko servisi" href="http://buyukcekmecebekoservisi.com">büyükçekmece beko servisi</a> i follow blog


26. büyükçekmece beko servisi Mar 10, 2010 at 23:56

thank you nice post


27. beylikdüzü arçelik servisi Mar 17, 2010 at 16:12

thanks nice post for beylikdüzü arçelik servisi


28. iz yapı Mar 17, 2010 at 16:54

We expect continued good topic thank you http://kesermakina.com


29. idasil Apr 03, 2010 at 07:10

basur basur tedavi hemoroid basur bitkisel tedavi basur bitkisel tedavi hemoroit


30. tesisat yıkama Apr 14, 2010 at 13:31

tesisat yikama ve temizleme hizmetleri


31. mitsubishi klima servisi Apr 16, 2010 at 16:52

mitsubishi klima bakım ve montaj servisi


32. beko klima servis Apr 18, 2010 at 12:12

beko klima servis bakım ve montaj servisi


33. arçelik klima servis Apr 18, 2010 at 23:09

arçeli klima servis, bakım ve montaj servisi


34. pergole Apr 19, 2010 at 02:26

pergole, pergole modelleri, pergole imalatı


35. nlp kimya Apr 19, 2010 at 15:34

kimya ve kimya ürünleri nlp kimya


36. Carter Eduardo May 13, 2010 at 02:07

Two factors are the is a high infant mortality rate in Africa, and there are lots of people dying from disease there. Families there have lots of children to counteract these problems.
<a href="http://www.anaheimwhitehousewedding.com/">rehearsal dinner</a>


37. rehearsal dinner May 13, 2010 at 02:08

The other is a guess (sorry) due to the warmer climate they tend to not be covered up for 1/2 of the year like many other places, therefore exposing their skin and bodies and causing the male arousal more often.


38. çemberleme makinası May 18, 2010 at 13:38

çemberleme makinası satışı ve pazarlama http://cembant.com.tr uzman ve kaliteli çözümler


39. eca servisi May 19, 2010 at 12:59

eca kombi ve klima servisi


40. ferroli servisi May 19, 2010 at 13:28

ferroli kombi ve klima servisi bakım arıza tüm ihtiyaçlarınız için hizmetinizdeyiz.


41. avcılar bosch servisi May 23, 2010 at 05:46

avcılar bosch beyaz eşya, klima, kombi ve ankastre servisi


42. fujitsu klima servisi May 23, 2010 at 05:46

fujitsu klima bakım ve montaj servisi


43. volkswagen servisi May 25, 2010 at 05:02

thank you


44. Orjin Krem May 26, 2010 at 04:58

tsekkür edrim


45. plastik şişirme May 27, 2010 at 22:58

plastik şişirme makinası imalat ve teknik destek keser makina makina bizim işimiz


46. kimya May 27, 2010 at 23:38

nlp kimya ürünler satış ve üretim


47. bosch servisi May 27, 2010 at 23:46

bosch beyaz eşya servisi


48. flash oyunlar Jun 21, 2010 at 02:57

sie I liked his hands thanks to your health.


49. ttnet adsl basvuru Jul 01, 2010 at 02:46

I like this kind of very useful articles congratulations I wish you continued success, I hope I can do this kind of article


50. MLB Jerseys shop Jul 08, 2010 at 00:01

I love it,Excellent article.I am decide to put this into use one of these days.Thank you for sharing this.To Your Success!


51. chanel shoes sale Jul 23, 2010 at 01:41

what cheap price you are willing to pay for them!


52. jordan shoe Jul 25, 2010 at 23:05

 Your website is so much nice i would like to see all the posts but i have dont enough time to do it. Over all i loved your all the articles


53. asics shose Jul 28, 2010 at 00:20

thanks for sharing.


54. beko servisi Aug 02, 2010 at 07:04

thanks for information


55. sanejenny Aug 03, 2010 at 08:37

After the conference, they will make many changes of their working systems. And all of the new system will be explained clearly in that conference.


58. beko servisi Aug 05, 2010 at 03:11

thanks for information


59. Boss Aug 05, 2010 at 10:41

<a href="http://www.dekowebtasarim.com" title="deko,web tasarım, web tasarım şirketleri, web tasarım şirketi, grafik tasarım, logo tasarım" target="_blank">Deko Web Tasarım</a>


59. teknospor Aug 05, 2010 at 15:17

thank you topic. i like your site and posts.


60. bamboo flooring Aug 08, 2010 at 16:42

Your post is rocking and knowledgeable... I really appreciate the way you write . I would like to read more from you.


61. avcılar bosch servisi Aug 11, 2010 at 08:57

thanksss


62. avcılar bosch servis Aug 12, 2010 at 00:48

thanks for information


63. site ekle Aug 12, 2010 at 02:52

thanks alot.


64. error fix Aug 16, 2010 at 04:41

Families there have lots of children to counteract these problems.


65. Ceoleq Aug 16, 2010 at 05:25

Thank You
<a href="http://www.ceoleq.com">Ceoleq.Com</a>


66. beko servisi Aug 16, 2010 at 07:13

thankss


67. jordan shoes on sale Aug 19, 2010 at 22:36

Thanks for screencast,Thanks a lot for your brilliant screencasts! They're one of the best Rails resources I know and extraordinarily well prepared.


68. pimapen Aug 23, 2010 at 18:31

Now being about 9 months into RoR I am still learning a lot of things I just didn't know existed.


69. alemdağ bosch servisi Aug 24, 2010 at 02:33

thankss for information


70. göztepe bosch servisi Aug 24, 2010 at 02:33

thankss


71. ataşehir bosch servisi Aug 24, 2010 at 02:33

thanks use


72. gürpınar bosch servisi Aug 24, 2010 at 02:34

thanks for information


73. cep oyun Aug 25, 2010 at 00:20

thank you veyr muchh


74. cep Aug 25, 2010 at 00:20

thank you very muchhh.


75. metin2 hile Aug 25, 2010 at 04:05

Thank You Very Nice Admin...


76. mega dosya Aug 25, 2010 at 04:06

Thanks a lot for your brilliant screencasts! They're one of the best Rails resources I know and extraordinarily well prepared.


77. louis vuitton shoes Aug 26, 2010 at 21:04

Thanks for sharing your article. I really enjoyed it. I put a link to my site to here so other people can read it. My readers have about the same interets


78. Wholesale Electronics Aug 27, 2010 at 00:52

Discount Wholesale Electronics, Wholesale Cell Phones, Electronic Gadgets and More from the Best Dropship Wholesaler


79. nike air max 2009 Aug 28, 2010 at 11:17

i agree with your point it very useful articles


80. I am so interested in it! Aug 30, 2010 at 01:29

I am so interested in it!


81. mbt shoe uk Aug 30, 2010 at 01:30

I am so interested in it!


82. beko servisi Aug 30, 2010 at 07:19

thanksss


83. snow boots Aug 31, 2010 at 00:17

 I spent a bit of time this morning trying to figure out how to get that file included in the patch, but haven't had much luck yet.


84. nuri Sep 01, 2010 at 01:15

Oww . Thanks :)


85. Dolce & Gabbana Belts Sep 01, 2010 at 22:50

There are certainly a lot of details like that to take into consideration. That is a great point to bring up. I offer the thoughts above as general inspiration but clearly there are questions like the one you bring up where the most important thing will be working in honest good faith

Add your comment:

(SKIP THIS ONE)

(required)

(not shown)


(use pastie or gist for code)

sponsored by:
if you want to help:
required:
Get Quicktime Player
Give Back to Open Source