Module: Customs::Statuses
- Defined in:
- lib/customs/statuses.rb
Class Method Summary collapse
Instance Method Summary collapse
- #access_denied ⇒ Object
- #options_for_status_code(code) ⇒ Object
- #template_for_status_code(code) ⇒ Object
- #unprocessable(*args) ⇒ Object
Class Method Details
.included(base) ⇒ Object
4 5 6 7 |
# File 'lib/customs/statuses.rb', line 4 def self.included base base.class_attribute :navigational_formats base. = [:html] end |
Instance Method Details
#access_denied ⇒ Object
21 22 23 24 |
# File 'lib/customs/statuses.rb', line 21 def access_denied return if self.respond_to?(:current_user) && !current_user forbidden end |
#options_for_status_code(code) ⇒ Object
45 46 47 |
# File 'lib/customs/statuses.rb', line 45 def code { :status => code, :template => template_for_status_code(code) } end |
#template_for_status_code(code) ⇒ Object
49 50 51 |
# File 'lib/customs/statuses.rb', line 49 def template_for_status_code code "customs/#{code}" end |
#unprocessable(*args) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/customs/statuses.rb', line 26 def unprocessable *args = args. respond_to do |format| format.any * do action = .delete(:action) action ||= case params[:action] when 'update' then 'edit' when 'create' then 'new' else raise "Unknown unprocessable action" end render :status => 422, :action => action end format.all { render :status => 422 } end end |