XML builder for Rails

xml.erb gone, xml.builder in

Controllers
def show
  @user = User.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.xml # show.xml.builder
  end
end


Views
show.xml.builder
xml.instruct!
xml.user do
  xml.login(@user.login, :type => :string)
  xml.email(@user.email, :type => :string)
  xml.firstname(@user.firstname, :type => :string)
  xml.lastname(@user.lastname, :type => :string)
end

你可能感兴趣的:(html,xml,Rails)