lib/plezi/handlers/controller_magic.rb in plezi-0.7.3 vs lib/plezi/handlers/controller_magic.rb in plezi-0.7.4
- old
+ new
@@ -129,15 +129,15 @@
response["content-disposition"] = content_disposition
response.finish
true
end
- # renders a template file (.erb/.haml) or an html file (.html) to text
- # for example, to render the file `body.html.haml` with the layout `main_layout.html.haml`:
+ # renders a template file (.slim/.erb/.haml) or an html file (.html) to text
+ # for example, to render the file `body.html.slim` with the layout `main_layout.html.haml`:
# render :body, layout: :main_layout
#
- # or, for example, to render the file `json.js.haml`
+ # or, for example, to render the file `json.js.slim`
# render :json, type: 'js'
#
# or, for example, to render the file `template.haml`
# render :template, type: ''
#
@@ -146,11 +146,11 @@
# block:: an optional block, in case the template has `yield`, the block will be passed on to the template and it's value will be used inplace of the yield statement.
#
# options aceept the following keys:
# type:: the types for the `:layout' and 'template'. can be any extention, such as `"json"`. defaults to `"html"`.
# layout:: a layout template that has at least one `yield` statement where the template will be rendered.
- # locale:: the I18n locale for the render. (defaults to params[:locale]) - only if the I18n gem namespace is defined (`require 'i18n'`).
+ # locale:: the I18n locale for the render. (defaults to params\[:locale]) - only if the I18n gem namespace is defined (`require 'i18n'`).
#
# if template is a string, it will assume the string is an
# absolute path to a template file. it will NOT search for the template but might raise exceptions.
#
# if the template is a symbol, the '_' caracters will be used to destinguish sub-folders (NOT a partial template).
@@ -191,11 +191,11 @@
# respond to save 'new' special case
return :save if request.request_method.match(/POST|PUT/) && params[:id].nil? || params[:id] == 'new'
# set DELETE method if simulated
request.request_method = 'DELETE' if params[:_method].to_s.downcase == 'delete'
# respond to special :id routing
- return params[:id].to_sym if params[:id] && self.class.available_public_methods.include?(params[:id].to_sym)
+ return params[:id].to_s.to_sym if params[:id] && self.class.available_public_methods.include?(params[:id].to_s.to_sym)
#review general cases
case request.request_method
when 'GET', 'HEAD'
return :index unless params[:id]
return :show
@@ -300,10 +300,14 @@
reset_routing_cache
end
# reviews the Redis connection, sets it up if it's missing and returns the Redis connection.
#
- # todo: review thread status? (incase an exception killed it)
+ # a Redis connection will be automatically created if the `ENV['PL_REDIS_URL']` is set.
+ # for example:
+ # ENV['PL_REDIS_URL'] = ENV['REDISCLOUD_URL']`
+ # or
+ # ENV['PL_REDIS_URL'] = "redis://username:password@my.host:6379"
def redis_connection
# return false unless defined?(Redis) && ENV['PL_REDIS_URL']
# return @@redis if defined?(@@redis_sub_thread) && @@redis
# @@redis_uri ||= URI.parse(ENV['PL_REDIS_URL'])
# @@redis ||= Redis.new(host: @@redis_uri.host, port: @@redis_uri.port, password: @@redis_uri.password)