dennismonsewicz
dennismonsewicz

Reputation: 25542

Render YAML in Rails 3

Is there anyway to respond_to a .yml file extension?

I have tried, but can't get it to work.

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

The above code spits out the following error uninitialized constant Mime::YML

Upvotes: 4

Views: 4188

Answers (2)

foomip
foomip

Reputation: 66

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

Upvotes: 5

Arkan
Arkan

Reputation: 6236

Try to add this into your environment.rb file :

Mime::Type.register 'text/yaml', :yaml

Upvotes: 3

Related Questions