Render YAML in Rails 3

Is there any way to respond to the .yml extension?

I tried, but can't make it work.

respond_to do |format|
      format.xml # index.xml.builder
      format.yml {render :text => @labels.to_yaml, :content_type => 'text/yaml'}
    end

In the above code, the following error is subtracted uninitialized constant Mime::YML

+3
source share
2 answers

No need to add this stuff to environment.rb, just change format.yml to format.yaml and it will work.

+4
source

Try adding this to your environment.rb file:

Mime::Type.register 'text/yaml', :yaml
+2
source

Source: https://habr.com/ru/post/1780944/


All Articles