View helpers in extensions

I’m still working on my asset handling plugin and I find myself needing
a
traditional rails helper method; i.e., something that I can call from a
page view and use to dynamically modify/insert stuff into the page. I’ve
been trying to add this functionality by creating a helper module (let’s
call it “assets_helper.rb”) to assist my controller (let’s call it
“assets_controller.rb”).

My helper is found in the following path

  /radiant_app/extensions/assets/app/helpers/assets_helper.rb

but for some reason it doesn’t seem to be loaded when the rest of the
radiant app starts … none of the methods defined in it are available
to
my views.

Is this a known problem, or am I just doing something wrong? Any
guidance
would be greatly appreciated.

I ran into a similar issue earlier (I’m porting the Mephisto asset
manager
over to Radiant extensions) and would be very interested in an answer to
the
same question.

Along the same lines, I’d also like to be able to extend the overall
application helper and application.rb from within an extension - is this
possible?

Thanks,
Kevin A.

On 3/15/07, Nathan W. [email protected] wrote:

  /radiant_app/extensions/assets/app/helpers/assets_helper.rb

Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant


BN23 Search Limited is Registered in England
Company Number: 5323555
VAT registration Number: 896 69 0062

BN23 Search Limited
Temple Grove
Compton Place Road
Eastbourne
East Sussex
BN20 8AD

Nathan W. wrote:

but for some reason it doesn’t seem to be loaded when the rest of the
radiant app starts … none of the methods defined in it are available to
my views.

You know, I don’t think we are doing anything special right now to
ensure that helpers are loaded. Probably we have to notify Rails of the
new helper directories, but we aren’t doing that right now.

Could you investigate a little more and let us know what we need to do?


John L.
http://wiseheartdesign.com

On 3/15/07, John W. Long [email protected] wrote:

Could you investigate a little more and let us know what we need to do?

“app/helpers” are added to default load paths on app init:
http://dev.rubyonrails.org/browser/trunk/railties/lib/initializer.rb?rev=6293#L551
http://dev.rubyonrails.org/browser/trunk/railties/lib/initializer.rb?rev=6293#L133

You should do the same manually with your helpers directory… or teach
Radiant extension system how to do it for you