Hey...
Controller:
class CategoriesController < ApplicationController
def create
@category = Category.create(...)
respond_to do |format|
if @category.save
format.xml { :status => :created }
else
format.xml { :status => :unprocessable_entity }
end
end
end
end
View:
xml.instruct! :xml, :version => "1.0"
xml.response do
xml.status( STATUS )
xml.code( STATUS CODE )
end
As you can see I set a status code inside my create controller action. My question is how can I read this status code inside view (e.g. STATUS CODE should be a number like 200 for OK, STATUS should be string like "OK", "Unauthorized"). I know I could create a variable e.g. @status = 'ok' but I do not want to duplicate code. Thx for the answer!