Class: Spree::BaseController

Inherits:
ApplicationController show all
Defined in:
app/controllers/spree/base_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#admin_created?

Methods included from EasyRoleRequirementSystem

included

Methods included from EasyRoleRequirementSystem::InstanceMethods

#included

Methods included from RoleRequirementSystem

included

Instance Method Details

#access_forbiddenObject



18
19
20
# File 'app/controllers/spree/base_controller.rb', line 18

def access_forbidden
  render :text => 'Access Forbidden', :layout => true, :status => 401
end

#default_titleObject



42
43
44
# File 'app/controllers/spree/base_controller.rb', line 42

def default_title
  Spree::Config[:site_name]
end

#find_orderObject

retrieve the order_id from the session and then load from the database (or return a new order if no such id exists in the session)



7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/spree/base_controller.rb', line 7

def find_order      
  unless session[:order_id].blank?
    @order = Order.find_or_create_by_id(session[:order_id])
  else      
    @order = Order.create
  end
  session[:order_id]    = @order.id
  session[:order_token] = @order.token
  @order
end

#initialize_extension_partialsObject

Used for pages which need to render certain partials in the middle of a view. Ex. Extra user form fields



24
25
26
# File 'app/controllers/spree/base_controller.rb', line 24

def initialize_extension_partials
  @extension_partials = []
end

#set_title(title) ⇒ Object

set_title can be used in views as well as controllers. e.g. <% set_title ‘This is a custom title for this view’ %>



30
31
32
# File 'app/controllers/spree/base_controller.rb', line 30

def set_title(title)
  @title = title
end

#titleObject



34
35
36
37
38
39
40
# File 'app/controllers/spree/base_controller.rb', line 34

def title
  if @title.blank?
    default_title
  else
    @title
  end
end