我正在尝试将事件呈现为ics和vcs。我有两个构建器设置
show.ics.erb
show.vcs.erb
但我不确定如何设置视图以做出相应的响应。我试过了:
respond_to do |format|
format.html { render :layout => "open_dashboard" }
format.ics { }
format.vcs { }
end
但这不起作用。日志包含:
Started GET "/events/1.vcal" for 127.0.0.1 at 2011-07-27 11:47:36 -0500
Processing by EventsController#show as
Parameters: {"id"=>"1"}
Consultation Load (0.9ms) SELECT "event".* FROM "events" WHERE "events"."id" = 1 LIMIT 1
User Load (34.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Rendered events/show.html.erb within layouts/open_dashboard (153.8ms)
Completed 406 Not Acceptable in 237ms (Views: 124.5ms | ActiveRecord: 35.2ms)
那么如何让它呈现正确的视图呢?
答案 0 :(得分:3)
您是否记得在config/initializers/mime_types.rb
注册自定义mime类型?
Mime::Type.register "text/calendar", :ics
之类的内容可能会为.ics
提供诀窍。