Module: Blog::BlogsHelper

Included in:
ApplicationController
Defined in:
app/helpers/blog/blogs_helper.rb

Instance Method Summary collapse

Instance Method Details

#allowable_htmlObject



4
5
6
# File 'app/helpers/blog/blogs_helper.rb', line 4

def allowable_html
  %w(br p a b ul li)
end

#construct_blog_path(blog_obj, action = 'index', context = nil, full_path = false) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/blog/blogs_helper.rb', line 8

def construct_blog_path(blog_obj, action='index', context=nil, full_path=false)
  context = blog_obj.context if context.nil?
  full_route = context.full_route.underscore

  rel_path = case action.to_s.intern
  when :index           then "/#{context.full_route}"
  when :create          then "/#{context.terse_route}" #main_app.send("#{full_route}_index_path")
  when :new, :edit      then main_app.send("#{action.to_s}_#{full_route.singularize}_path")
  when :show, :update, :delete then main_app.send("#{full_route.singularize}_path", blog_obj.title_for_url)
  end

  full_path ? "#{root_url}#{rel_path.gsub(/^\//,'')}" : rel_path
end

#posted_by_on(blog) ⇒ Object



22
23
24
# File 'app/helpers/blog/blogs_helper.rb', line 22

def posted_by_on(blog)
  "Posted by #{blog.user.email} on <time datetime='#{blog.created_at}'>#{blog.created_at.to_s(:created_at)}</time>".html_safe
end