#rubyonrails - Sat 31 Mar 2007 between 18:36 and 18:42

NY Lost Funds



Skiz_ypSami: if you are using postgres you can use CTI plugin for those extra attribs
PalishI guess I just stuck it in application.rb
stick
ypSamimysql here, Skiz_, but thank you =)
Skiz_Palish: what kind of helpers?
like for a controller?
PalishSkiz_: they're functions which take an input and return an output.
many controllers use them.
Skiz_well make a module in lib/ and just include it in application.rb
Palishohh
What would that file look like?
Skiz_module SpecialStuff ;; def wtf(var) ;; "YEAH WTF #{var}" ;; end ;; end <-- save it as lib/special_stuff.rb
Palishcan I Just have functions in it, or does it need to be in its own class?
Skiz_no class needed
Palishsweet
then I can just do wtf('lawl')?
Skiz_yup
Palishawesome.
Skiz_after you include it in your application class
its just a mixin
just remember you need to restart your app if you edit it
Palishrequire I guess
require 'special_stuff.rb'?
or lib/special_stuff.rb
Skiz_include SpecialStuff in the controller
PalishCould you give me the syntax? I haven't seen that before, but once I learn once I'll have learned it.
Skiz_google up ruby mixins for more details
http://www.rubycentral.com/book/tut_modules.html
Palishclass ApplicationController < ApplicationController::Base, SpecialStuff
like that?
and do require 'lib/special_stuff.rb' before that
Skiz_class AppCon... ;; include SpecialStuff ;;
I dont think you need to require before the class for modules in lib/ but you may. try it
Palishoh okay.
so even in a development environment, if I modify the module I have to restart?
Skiz_yes
Palishwow.
Skiz_so best bet is to write them in application.rb then move them out
Palishyeah
:(

Page: 3 10 17 24 31 38 45 52 59 66 73 80 

IrcArchive

NY Lost Funds