2012-06-22 40 views
2

我在文件夾「api」中有一個控制器「ott_controller.rb」。命名空間控制器的Rails助手文件?

我的路線是這樣的: map.namespace :api, :path_prefix => 'api' do |api| api.connect 'ott/playlists/:id.xml', :controller => 'ott', :action => 'playlists', :conditions => { :method => :get } end

我想創建這樣的幫手文件,但我不能把它撿起。

在助手文件夾,我已經試過以下

  1. 文件 「ott_helper.rb」 與模塊 「OttHelper」
  2. 文件 「api_ott_helper.rb」 與模塊 「OttHelper」
  3. 文件「ott_helper.rb」 與模塊 「阿比:: OttHelper」
  4. 文件 「api_ott_helper.rb」 與模塊 「阿比:: OttHelper」 這些工作

無。

這是一個導軌2項目。

任何想法?

回答

3

你命名空間中的輔助文件,以及?這應該工作:

app/helpers/api/ott_helper.rb

在文件:

module Api::OttHelper

+0

其實我也試過,但無濟於事 – Brian

+0

奇怪。我有一個名稱空間的Rails 2應用程序,並可以確認它的工作。所以,如果你安排之類的東西:'應用程序/控制器/ API/ott_controller.rb','應用程序/視圖/ API/OTT/playlists.html.erb'和'應用程序/傭工/ API/ott_helper.rb'播放列表視圖是無法訪問輔助方法? –