Module: Blogit::ApplicationHelper
- Defined in:
- app/helpers/blogit/application_helper.rb
Constant Summary
- TIMETAG_FORMAT =
"%Y-%m-%dT%TZ"
Instance Method Summary (collapse)
-
- (Object) actions(content_or_options = {}, options = {}, &block)
A helper method for creating a <div> tag with class ‘actions’ Used for option links and form buttons.
-
- (Object) errors_on(object, attribute)
Returns the first error message for an ActiveRecord model instance.
-
- (Object) field(content_or_options = {}, options = {}, &block)
A helper method for creating a <div> tag with class ‘field’ Used for separating form fields.
-
- (Object) login_required(content_or_options = {}, options = {}, &block)
A helper method for creating a <div> tag with class ‘login_required’ Will only render content if there is a logged in user.
-
- (Object) time_tag(time_object, format = nil, options = {})
Returns an HTML 5 time tag.
Instance Method Details
- (Object) actions(content_or_options = {}, options = {}, &block)
A helper method for creating a <div> tag with class ‘actions’ Used for option links and form buttons
22 23 24 |
# File 'app/helpers/blogit/application_helper.rb', line 22 def actions(={}, ={}, &block) div_with_default_class(:actions, , , &block) end |
- (Object) errors_on(object, attribute)
Returns the first error message for an ActiveRecord model instance
10 11 12 |
# File 'app/helpers/blogit/application_helper.rb', line 10 def errors_on(object, attribute) object.errors[attribute].first.to_s end |
- (Object) field(content_or_options = {}, options = {}, &block)
A helper method for creating a <div> tag with class ‘field’ Used for separating form fields
16 17 18 |
# File 'app/helpers/blogit/application_helper.rb', line 16 def field(={}, ={}, &block) div_with_default_class(:field, , , &block) end |
- (Object) login_required(content_or_options = {}, options = {}, &block)
A helper method for creating a <div> tag with class ‘login_required’ Will only render content if there is a logged in user
28 29 30 |
# File 'app/helpers/blogit/application_helper.rb', line 28 def login_required(={}, ={}, &block) div_with_default_class(:login_required, , , &block) if current_blogger end |
- (Object) time_tag(time_object, format = nil, options = {})
Returns an HTML 5 time tag
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/helpers/blogit/application_helper.rb', line 36 def time_tag(time_object, format = nil, ={}) # if there's a specified format and it's a string, assume it's an strftime string if format && format.is_a?(String) time_string = time_object.strftime(format) # if there's a specified format and it's a symbol, assume it's a predefined format elsif format && format.is_a?(Symbol) time_string = time_object.to_s(format) else time_string = time_object.to_s end .merge(datetime: time_object.strftime(TIMETAG_FORMAT)) content_tag(:time, time_string, ) end |