Sha256: e0d47dd8f44467e73278008df7441d3480807a6533d62875f370feb19126d8b3

Contents?: true

Size: 1.2 KB

Versions: 19

Compression:

Stored size: 1.2 KB

Contents

module MuckContentsHelper
  
  # share is an optional share object that can be used to pre populate the form.
  # content:  Optional content object to be edited.
  # options:  html options for form.  For example:
  #             :html => {:id => 'a form'}
  def content_form(content = nil, options = {}, &block)
    content ||= Content.new
    options[:html] = {} if options[:html].nil?
    raw_block_to_partial('contents/form', options.merge(:content => content), &block)
  end
  
  # content uses friendly_id but we want the param in the form to use the number id
  def get_content_form_url(parent, content)
    if content.new_record?
      polymorphic_url([parent, content])
    else
      # HACK there should be a way to force polymorphic_url to use an id instead of to_param
      polymorphic_url([@parent, @content]).gsub(@content.to_param, "#{@content.id}") # force the id.  The slugs can cause problems during edit
    end
  end
  
  def show_preview(content)
    if content.new_record?
      %Q{<a style="display:none;" target="blank" id="preview" href="#">#{t('muck.contents.preview')}</a>}
    else
      %Q{<a id="preview" target="blank" href="#{content.uri}">#{t('muck.contents.preview')}</a>}
    end
  end
  
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
muck-contents-0.2.17 app/helpers/muck_contents_helper.rb
muck-contents-0.2.16 app/helpers/muck_contents_helper.rb
muck-contents-0.2.15 app/helpers/muck_contents_helper.rb
muck-contents-0.2.14 app/helpers/muck_contents_helper.rb
muck-contents-0.2.13 app/helpers/muck_contents_helper.rb
muck-contents-0.2.12 app/helpers/muck_contents_helper.rb
muck-contents-0.2.11 app/helpers/muck_contents_helper.rb
muck-contents-0.2.10 app/helpers/muck_contents_helper.rb
muck-contents-0.2.9 app/helpers/muck_contents_helper.rb
muck-contents-0.2.8 app/helpers/muck_contents_helper.rb
muck-contents-0.2.7 app/helpers/muck_contents_helper.rb
muck-contents-0.2.6 app/helpers/muck_contents_helper.rb
muck-contents-0.2.5 app/helpers/muck_contents_helper.rb
muck-contents-0.2.4 app/helpers/muck_contents_helper.rb
muck-contents-0.2.3 app/helpers/muck_contents_helper.rb
muck-contents-0.2.2 app/helpers/muck_contents_helper.rb
muck-contents-0.2.1 app/helpers/muck_contents_helper.rb
muck-contents-0.2.0 app/helpers/muck_contents_helper.rb
muck-contents-0.1.12 app/helpers/muck_contents_helper.rb