Module: RailsCaddyHelper

Defined in:
lib/rails-caddy/helpers/rails_caddy_helper.rb

Instance Method Summary collapse

Instance Method Details

#rails_caddyObject

actually embeds the magic that is the Rails Caddy



3
4
5
# File 'lib/rails-caddy/helpers/rails_caddy_helper.rb', line 3

def rails_caddy
  render(:partial => '/rails_caddy')
end

#rc_in_place_editor(key, field_id, url) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/rails-caddy/helpers/rails_caddy_helper.rb', line 12

def rc_in_place_editor(key, field_id, url)
  function =  "RailsCaddy.editors['" + key + "'] = new Ajax.InPlaceEditor("
  function << "'#{field_id}', "
  function << "'#{url}'"
  function << ');'

  javascript_tag(function)
end

#rc_in_place_editor_field(key, value) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rails-caddy/helpers/rails_caddy_helper.rb', line 21

def rc_in_place_editor_field(key, value)
  tag = ::ActionView::Helpers::InstanceTag.new("rails_caddy", key, self)
  tag_options = {:tag => "span", :id => "rails_caddy_#{key}_in_place_editor", :name => "value", :class => "in_place_editor_field"}
  
  # rails < 2.3 needs to be treated with kid gloves.
  url = update_session_path
  url << "/" unless url.match(/\/$/)
  url << key
  
  tag.(tag_options.delete(:tag), value, tag_options) + rc_in_place_editor(key, tag_options[:id], url)
end

#translated_remove_session_pathObject



7
8
9
10
# File 'lib/rails-caddy/helpers/rails_caddy_helper.rb', line 7

def translated_remove_session_path
  url = remove_session_path
  url << "/" unless url.match(/\/$/)
end