Class: RenderRealTimeController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- RenderRealTimeController
- Defined in:
- lib/real_time_rails/render_real_time_controller.rb
Instance Method Summary collapse
-
#id ⇒ Object
Updates will pull data from this controller.
Instance Method Details
#id ⇒ Object
Updates will pull data from this controller. url in the form of ‘/render_real_time/id/#md5_hash_id’ The information is pulled from Rails.cache by the md5 hash id
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/real_time_rails/render_real_time_controller.rb', line 7 def id = YAML.load(Rails.cache.read("real_time_#{params[:id]}")) = YAML.load(Rails.cache.read("real_time_#{params[:id]}_options")) locals = {} [:models].each do |rtmodel| case rtmodel[:type] when :single locals[rtmodel[:key]] = eval("#{rtmodel[:name]}.find(rtmodel[:id])") when :array locals[rtmodel[:key]] = eval("#{rtmodel[:name]}.find(rtmodel[:ids])") when :relation rtmodel[:sql] = rtmodel[:sql].gsub('\"','"') locals[rtmodel[:key]] = eval("#{rtmodel[:name]}.find_by_sql(rtmodel[:sql])") #TODO This needs to recreate the arel object. Not just find_by_sql. else end end render :update do |page| page.replace_html params[:id], :partial => [:partial], :locals => locals end end |