#64
Jul 30, 2007

Custom Helper Modules

Rails designates one helper module per controller, but that shouldn't stop you from making custom helper modules to help structure the code. Learn how in this episode.
Download (18.6 MB, 5:06)
alternative download for iPod & Apple TV (9 MB, 5:06)

RSS Feed for Episode Comments 31 comments

1. Drew Jul 30, 2007 at 01:11

Hey, where's the code snippet on this one?

You have us spoiled with those!


2. Stijn Goris Jul 30, 2007 at 01:20

Only 1 a week? My weeks will be much more boring :-)

Many thanks for all the great screencasts.


3. pimpmaster Jul 30, 2007 at 01:40

I really enjoyed this and am already refactoring 2 of my apps. Sweet!!

@ Drew

If you watch this one you will see that it's just simple organization of code.

@Stijn

I totally agree.. One railscast per week is totally unacceptable for my raging habit. I may need to join a support group or 12-step program for getting off Ryan's Rails-Crack


4. chineseGuy Jul 30, 2007 at 02:42

nice!~


5. InMan Jul 30, 2007 at 03:16

Hey.

Good cast. Haven't tried this approach, but I will :).

One railscast per week.. that's sad news. Atleast it's something, and now Ryan has time to put up maybe even something more complicated cast.


6. Dejan Dimic Jul 30, 2007 at 05:30

Even as I know that this is a hard work to create and produce such great screen casts every week, I will be sad if I have to wait whole week for a new pearl of wisdom.

Please reconsider you intention and make us all happy and better developers.


7. riki Jul 30, 2007 at 07:02

Hi Ryan

these are great, you should start charging :)


8. Gary Jul 30, 2007 at 07:39

Hey Ryan, Once a week is fine by me ;-) I'm getting information overload here!!


9. jc Jul 30, 2007 at 09:18

He's gotta be running out of screencast ideas. We'll all need to email him a new idea for railscasts. All at once.


10. David Parker Jul 30, 2007 at 10:10

One a week is sad, but it is definitely a lot to sink my teeth into as it is... keep up the good work Ryan!


11. Michael Jul 30, 2007 at 10:53

Thank you for all the great railscasts Ryan. They have truly improved my coding! Following up on some of the previous comments, I think a section of the site for suggested topics would be useful for ideas. Also maybe instead of 1 railscast for "free" each week perhaps you can do 2 per week but the 2nd one is only available to donating members and is unlocked the following week for non-donating members to view. You do excellent work and I think it's only fair you should be compensated in return for it.


12. Ted Jul 30, 2007 at 15:06

Aw, only one a week :-(

I can't knock you for wanting a break but I've had no problem at all digesting them at the rate you're pumping them out :-)

Thanks for all the hard work.


13. Daniel Jul 30, 2007 at 16:33

Thanks Ryan for all your hard work.
Although I could happily view a new Railscast every day, this will give me a chance to go over the older ones again.
You've created a great collection to supplement the Peepcode shows.


14. Nadav Jul 31, 2007 at 05:23

Thanks for your effort.
These casts are truely fantastic.


15. Piku Jul 31, 2007 at 06:39

One Railscast a week is a bit sad, but I can live with it.
Maybe if we start donating we'll help Ryan with his great work.
I also like Michael's ideea.


16. Rob Aug 01, 2007 at 07:06

Every Monday, Wednesday, and Friday I made it a ritual to get up first thing in the morning, load Google Reader, and excite myself seeing 'Railscasts (1)'. Unfortunately, that ritual can only happen on Monday now. With this happening, and the fact that Mr. Peepcode is releasing screencasts in shorter "parts" now to get more money, I can't help but feel the Rails community is dying. Please resurrect it. You are our savior.


17. Mark Aug 01, 2007 at 12:22

I really enjoy watching the RailsCasts. They teach me -a RoR-beginner- a lot. Keep up the good work, even it's "only" once a week.


18. Din00z Aug 01, 2007 at 12:49

Today my day is a little different, Basketball just like any other Mon-Wed-Fri, however no new railscasts videos to download. I learn a lot from this videos and like to thank Ryan for the hard and great work. How much is worth it to the RoR community to keep the site up ??? at least to pay for a good meal or a monthly apartment rent!!!. Can't wait to buy a railscasts T-shirt, donate to the PayPal site, guys if all of us enjoy the videos as much as I do, we should try to keep it alive, but that will take time, energy and resources. Perhaps add a section for volunteer tutorials, leave the main tutorials for Ryan on monday and complement on the Wed and Fri with contributions of the RoR community, perhaps in different languajes ;-)


19. Ryan Bates Aug 01, 2007 at 13:27

Don't worry, Railscasts isn't going anywhere. I may still do three a week once and a while when I have the time, just don't count on it being a regular occurrence. This will give me some more time to catch up on the other things I've been putting off.


20. cbmeeks Aug 02, 2007 at 05:06

Great screen cast.

I would suggest Ryan do one per week but make them much longer.

And/Or, do a 1-2 HOUR screen cast on a really detailed subject and sell them. But that would compete with Peepcode. Maybe he could sell them through Peepcode.
cbmeeks
http://www.signaldev.com


21. Drew S Aug 02, 2007 at 09:09

I just got into railscasts, so this move to 1 a week is even more shocking to me. Until recently, I was able to watch one new 'cast a day, but now that I'm caught up, one a week seems like an even bigger shock to most. Anyway, great work! I look forward to future "lessons" no matter how infrequent.


22. Ryan Aug 03, 2007 at 05:12

I completely understand only doing 1 per week -- personally, I would like 10 per week! You're doing a great job...

As a future screencast request, maybe sometime you could explain method_missing and show one or two clever ways it can be used? Just a thought... Keep up the good work!


23. Gavin Aug 03, 2007 at 05:58

I am in agreement with others that one a week won't satisfy my need for your railscasts but can appreciate the time needed to make and edit them, perhaps now that your only doing one a week they can be a little longer? Anyway, thanks for the great content you have already provided


24. MrWizard Aug 04, 2007 at 03:58

I had to laugh at the comments about one a week. I discovered railscasts this morning and I've just watched all 64! It's been a fantastic way to spend a rainy Saturday. Keep up the good work!


25. Dougal Aug 06, 2007 at 06:07

I've always thought the frequency and quality of the content was fantastic. I really appreciate all the work you've put into Railscasts, an excellent resource.


26. pimpmaster Aug 14, 2007 at 17:22

Steering things back on topic, I ran into an issue refactoring some helpers. Apparently any helper with the url_for method doesnt work anywhere else but the application_helper file.

I tried many different ways but Rails seems pretty unbending in this aspect.


27. Hallison Batista Dec 07, 2007 at 13:40

Hi Ryan.

I use your tip, but my server thow an exception: (part of message)

Missing helper file helpers/all_helper.rb
./script/../config/../vendor/rails/actionpack/lib/action_controller/helpers.rb:71:in `helper'
./script/../config/../vendor/rails/actionpack/lib/action_controller/helpers.rb:58:in `each'
./script/../config/../vendor/rails/actionpack/lib/action_controller/helpers.rb:58:in `helper'
./script/../config/../app/controllers/application.rb:7
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:204:in `load_without_new_constant_marking'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:204:in `load_file'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:343:in `new_constants_in'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:203:in `load_file'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:95:in `require_or_load'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:61:in `depend_on'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:443:in `require_dependency'
./script/../config/../vendor/rails/railties/lib/dispatcher.rb:110:in `prepare_application'
./script/../config/../vendor/rails/railties/lib/dispatcher.rb:39:in `dispatch'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:113:in `handle_dispatch'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:79:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:63:in `dispatch'
./script/../config/../vendor/rails/railties/lib/commands/servers/webrick.rb:59
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in `require'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:343:in `new_constants_in'
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in `require'
./script/../config/../vendor/rails/railties/lib/commands/server.rb:39
./script/server:5:in `require'
./script/server:5
Missing helper file helpers/all_helper.rb
./script/../config/../vendor/rails/actionpack/lib/action_controller/helpers.rb:71:in `helper'
./script/../config/../vendor/rails/actionpack/lib/action_controller/helpers.rb:58:in `each'
./script/../config/../vendor/rails/actionpack/lib/action_controller/helpers.rb:58:in `helper'
./script/../config/../app/controllers/application.rb:7

My helpers:

- html_content_helper
- opcoes_controle_helper
- paginacao_helper

Do you help me?

PS: My Rails version is 1.2.6


28. Ruby Dec 18, 2007 at 10:13

Hallison,
 I am having the same experience of the missing all_helper.rb with a reinstall on a shared server. If you find out the cause of your error would you be kind enough to post it here? The host has not been able to help and I am going nuts.
My rails version is 1.2.3
Thank you


29. Bernardo Mar 17, 2008 at 12:02

Ruby and Hallison: You need to use rails edge (or 2.0) for that. Pay attention, Ryan says that in the cast!


30. kino May 23, 2008 at 01:52

By virtue of my free epoche with respect to the being of the experienced world, the momentous fact is that, by reconciling with experiences, only in reflection do we "direct" ourselves to the Objective world and to its perceptual directedness to separated modes of consciousness.


31. ram Aug 26, 2008 at 12:02

good, useful

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