Brian
Brian

Reputation: 7135

Rails helper file for a namespaced controller?

I have a controller "ott_controller.rb" in the folder "api".

My routes look like this: map.namespace :api, :path_prefix => 'api' do |api| api.connect 'ott/playlists/:id.xml', :controller => 'ott', :action => 'playlists', :conditions => { :method => :get } end

I'm trying to create a helper file for this, but I can't get it to pick up.

In the helpers folder, I've tried the following

  1. File "ott_helper.rb" with module "OttHelper"
  2. File "api_ott_helper.rb" with module "OttHelper"
  3. File "ott_helper.rb" with module "Api::OttHelper"
  4. File "api_ott_helper.rb" with module "Api::OttHelper"

None of those work.

This is a rails 2 project.

Any ideas?

Upvotes: 2

Views: 2454

Answers (1)

Tom L
Tom L

Reputation: 3409

Did you namespace the helper file as well? This should work:

app/helpers/api/ott_helper.rb

In the file:

module Api::OttHelper

Upvotes: 3

Related Questions