2012-05-21 31 views
1

在Rails中,我試圖實現移動視圖。剛安裝的mobylette寶石似乎比mobile_fu有更近的活動。ActionView :: MissingTemplate:Missing template:formats => [:mobile]

https://github.com/tscolari/mobylette

然而,大部分來自移動設備的請求的結束了這個錯誤

ActionView::MissingTemplate: Missing template my_controller/index, application/index with {:locale=>[:en], :formats=>[:mobile], :handlers=>[:erb, :builder, :haml]}. Searched in: * "/app/app/views" * "/app/vendor/bundle/ruby/1.9.1/gems/devise-1.5.2/app/views" * "/app/app/views" 

任何想法,爲什麼?

+0

什麼是您的模板文件?你可以給路徑相對於鐵路的根請 –

+0

當我試圖創建一個新的用戶從移動設備使用默認操作'devise/registrations/create'創建一個新的用戶。 – Martin

回答

0

您可能需要添加自己的移動格式。

在配置/初始化/ mime_types.rb,添加:

Mime::Type.register_alias "text/html", :mobile 
+0

即使如此,仍然無法正常工作。同樣的錯誤。 – Martin

+0

你重新啓動了導軌嗎? – vise

+0

是的,我做了上一個。 – Martin

0

如果您設置MIME類型,並有respond_to :mobile在你的控制器,你唯一的問題應該是移動模板文件實際上丟失。

默認情況下,你必須叫<action>.<format>.<handler> or <action>.<handler>

我懷疑默認色器件模板(後成功創建重定向展現動作)適當view_path一個模板文件show.html.erb

你最安全的賭注是創建符號鏈接或它(和所有其他行動)

ln -sf show.html.erb show.mobile.erb # in linux 

在哪裏?好吧,如果你使用的色器件rake任務

rails generate devise:views 

,那麼你知道這將是下app/views/devise/registrations

如果設置config.scoped_views = trueconfig/initializers/devise.rb,那麼這將是app/views/users/registrations下給出你的色器件模型是用戶使用UsersController 。

相關問題