简体   繁体   中英

Rails cache saved files with wrong extension

I have mime type defined

Mime::Type.register "text/html", :demo

and controller which looks like this:

  caches_page :show
  def show
    .....
    render_location
  end

  def render_location
    ...
    respond_to do |format|
      format.html {
        expires_in 3.days, :public=>true
      }
      format.demo {
        headers['Content-type']  = 'text/html'
        render 'fields.html.erb', layout:nil
      }
      format.json do
        out = {
          :promo_text => 'text',
          :currencies => 'eee'
        }
        render json: out
      end
    end
  end

Route is set lite this:

get '/prefix/*place', to: 'locations#show', as: 'location', defaults: {format:'html'}

For some reason file in cache folder is saved with .demo extension even when I request for "prefix/some-place"

I can't understand why this happens.

我发现,如果自定义扩展与另一个演示文稿共享Content-type,则必须使用register_alias对其进行定义。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM