Module: ActivityNotification::ViewHelpers
- Defined in:
- lib/activity_notification/helpers/view_helpers.rb
Overview
Provides a shortcut from views to the rendering method. Module extending ActionView::Base and adding ‘render_notification` helper.
Instance Method Summary collapse
-
#move_notification_path_for(notification, params = {}) ⇒ String
Returns move_notification_path for the target of specified notification.
-
#move_notification_url_for(notification, params = {}) ⇒ String
Returns move_notification_url for the target of specified notification.
-
#notification_path_for(notification, params = {}) ⇒ String
Returns notification_path for the notification.
-
#notification_url_for(notification, params = {}) ⇒ String
Returns notification_url for the target of specified notification.
-
#notifications_path_for(target, params = {}) ⇒ String
Returns notifications_path for the target.
-
#notifications_url_for(target, params = {}) ⇒ String
Returns notifications_url for the target.
-
#open_all_notifications_path_for(target, params = {}) ⇒ String
Returns open_all_notifications_path for the target.
-
#open_all_notifications_url_for(target, params = {}) ⇒ String
Returns open_all_notifications_url for the target of specified notification.
-
#open_notification_path_for(notification, params = {}) ⇒ String
Returns open_notification_path for the target of specified notification.
-
#open_notification_url_for(notification, params = {}) ⇒ String
Returns open_notification_url for the target of specified notification.
-
#render_notification(notifications, options = {}) ⇒ String
(also: #render_notifications)
View helper for rendering an notification, calls Notification#render internally.
-
#render_notification_of(target, options = {}) ⇒ String
(also: #render_notifications_of)
View helper for rendering on notifications of the target to embedded partial template.
-
#subscribe_subscription_path_for(subscription, params = {}) ⇒ String
(also: #subscribe_path_for)
Returns subscribe_subscription_path for the target of specified subscription.
-
#subscribe_subscription_url_for(subscription, params = {}) ⇒ String
(also: #subscribe_url_for)
Returns subscribe_subscription_url for the target of specified subscription.
-
#subscribe_to_email_subscription_path_for(subscription, params = {}) ⇒ String
(also: #subscribe_to_email_path_for)
Returns subscribe_to_email_subscription_path for the target of specified subscription.
-
#subscribe_to_email_subscription_url_for(subscription, params = {}) ⇒ String
(also: #subscribe_to_email_url_for)
Returns subscribe_to_email_subscription_url for the target of specified subscription.
-
#subscribe_to_optional_target_subscription_path_for(subscription, params = {}) ⇒ String
(also: #subscribe_to_optional_target_path_for)
Returns subscribe_to_optional_target_subscription_path for the target of specified subscription.
-
#subscribe_to_optional_target_subscription_url_for(subscription, params = {}) ⇒ String
(also: #subscribe_to_optional_target_url_for)
Returns subscribe_to_optional_target_subscription_url for the target of specified subscription.
-
#subscription_path_for(subscription, params = {}) ⇒ String
Returns subscription_path for the subscription.
-
#subscription_url_for(subscription, params = {}) ⇒ String
Returns subscription_url for the subscription.
-
#subscriptions_path_for(target, params = {}) ⇒ String
Returns subscriptions_path for the target.
-
#subscriptions_url_for(target, params = {}) ⇒ String
Returns subscriptions_url for the target.
-
#unsubscribe_subscription_path_for(subscription, params = {}) ⇒ String
(also: #unsubscribe_path_for)
Returns unsubscribe_subscription_path for the target of specified subscription.
-
#unsubscribe_subscription_url_for(subscription, params = {}) ⇒ String
(also: #unsubscribe_url_for)
Returns unsubscribe_subscription_url for the target of specified subscription.
-
#unsubscribe_to_email_subscription_path_for(subscription, params = {}) ⇒ String
(also: #unsubscribe_to_email_path_for)
Returns unsubscribe_to_email_subscription_path for the target of specified subscription.
-
#unsubscribe_to_email_subscription_url_for(subscription, params = {}) ⇒ String
(also: #unsubscribe_to_email_url_for)
Returns unsubscribe_to_email_subscription_url for the target of specified subscription.
-
#unsubscribe_to_optional_target_subscription_path_for(subscription, params = {}) ⇒ String
(also: #unsubscribe_to_optional_target_path_for)
Returns unsubscribe_to_optional_target_subscription_path for the target of specified subscription.
-
#unsubscribe_to_optional_target_subscription_url_for(subscription, params = {}) ⇒ String
(also: #unsubscribe_to_optional_target_url_for)
Returns unsubscribe_to_optional_target_subscription_url for the target of specified subscription.
Instance Method Details
#move_notification_path_for(notification, params = {}) ⇒ String
Needs any other better implementation
Must handle devise namespace
Returns move_notification_path for the target of specified notification
109 110 111 112 113 114 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 109 def move_notification_path_for(notification, params = {}) = params.dup .delete(:devise_default_routes) ? send("move_#{routing_scope()}notification_path", notification, ) : send("move_#{routing_scope()}#{notification.target.to_resource_name}_notification_path", notification.target, notification, ) end |
#move_notification_url_for(notification, params = {}) ⇒ String
Needs any other better implementation
Must handle devise namespace
Returns move_notification_url for the target of specified notification
179 180 181 182 183 184 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 179 def move_notification_url_for(notification, params = {}) = params.dup .delete(:devise_default_routes) ? send("move_#{routing_scope()}notification_url", notification, ) : send("move_#{routing_scope()}#{notification.target.to_resource_name}_notification_url", notification.target, notification, ) end |
#notification_path_for(notification, params = {}) ⇒ String
Needs any other better implementation
Must handle devise namespace
Returns notification_path for the notification
95 96 97 98 99 100 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 95 def notification_path_for(notification, params = {}) = params.dup .delete(:devise_default_routes) ? send("#{routing_scope()}notification_path", notification, ) : send("#{routing_scope()}#{notification.target.to_resource_name}_notification_path", notification.target, notification, ) end |
#notification_url_for(notification, params = {}) ⇒ String
Needs any other better implementation
Must handle devise namespace
Returns notification_url for the target of specified notification
165 166 167 168 169 170 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 165 def notification_url_for(notification, params = {}) = params.dup .delete(:devise_default_routes) ? send("#{routing_scope()}notification_url", notification, ) : send("#{routing_scope()}#{notification.target.to_resource_name}_notification_url", notification.target, notification, ) end |
#notifications_path_for(target, params = {}) ⇒ String
Needs any other better implementation
Must handle devise namespace
Returns notifications_path for the target
81 82 83 84 85 86 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 81 def notifications_path_for(target, params = {}) = params.dup .delete(:devise_default_routes) ? send("#{routing_scope()}notifications_path", ) : send("#{routing_scope()}#{target.to_resource_name}_notifications_path", target, ) end |
#notifications_url_for(target, params = {}) ⇒ String
Needs any other better implementation
Must handle devise namespace
Returns notifications_url for the target
151 152 153 154 155 156 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 151 def notifications_url_for(target, params = {}) = params.dup .delete(:devise_default_routes) ? send("#{routing_scope()}notifications_url", ) : send("#{routing_scope()}#{target.to_resource_name}_notifications_url", target, ) end |
#open_all_notifications_path_for(target, params = {}) ⇒ String
Needs any other better implementation
Must handle devise namespace
Returns open_all_notifications_path for the target
137 138 139 140 141 142 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 137 def open_all_notifications_path_for(target, params = {}) = params.dup .delete(:devise_default_routes) ? send("open_all_#{routing_scope()}notifications_path", ) : send("open_all_#{routing_scope()}#{target.to_resource_name}_notifications_path", target, ) end |
#open_all_notifications_url_for(target, params = {}) ⇒ String
Needs any other better implementation
Must handle devise namespace
Returns open_all_notifications_url for the target of specified notification
207 208 209 210 211 212 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 207 def open_all_notifications_url_for(target, params = {}) = params.dup .delete(:devise_default_routes) ? send("open_all_#{routing_scope()}notifications_url", ) : send("open_all_#{routing_scope()}#{target.to_resource_name}_notifications_url", target, ) end |
#open_notification_path_for(notification, params = {}) ⇒ String
Needs any other better implementation
Must handle devise namespace
Returns open_notification_path for the target of specified notification
123 124 125 126 127 128 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 123 def open_notification_path_for(notification, params = {}) = params.dup .delete(:devise_default_routes) ? send("open_#{routing_scope()}notification_path", notification, ) : send("open_#{routing_scope()}#{notification.target.to_resource_name}_notification_path", notification.target, notification, ) end |
#open_notification_url_for(notification, params = {}) ⇒ String
Needs any other better implementation
Must handle devise namespace
Returns open_notification_url for the target of specified notification
193 194 195 196 197 198 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 193 def open_notification_url_for(notification, params = {}) = params.dup .delete(:devise_default_routes) ? send("open_#{routing_scope()}notification_url", notification, ) : send("open_#{routing_scope()}#{notification.target.to_resource_name}_notification_url", notification.target, notification, ) end |
#render_notification(notifications, options = {}) ⇒ String Also known as: render_notifications
View helper for rendering an notification, calls Notification#render internally.
17 18 19 20 21 22 23 24 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 17 def render_notification(notifications, = {}) if notifications.is_a? ActivityNotification::Notification notifications.render self, elsif notifications.respond_to?(:map) return nil if notifications.empty? notifications.map {|notification| notification.render self, .dup }.join.html_safe end end |
#render_notification_of(target, options = {}) ⇒ String Also known as: render_notifications_of
Show examples
View helper for rendering on notifications of the target to embedded partial template. It calls Notification#render to prepare view as ‘content_for :index_content` and render partial index calling `yield :index_content` internally. For example, this method can be used for notification index as dropdown in common header.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 56 def render_notification_of(target, = {}) return unless target.is_a? ActivityNotification::Target # Prepare content for notifications index = .merge( target: target.to_resources_name, partial: [:notification_partial], layout: [:notification_layout] ) = .slice( :limit, :reverse, :with_group_members, :as_latest_group_member, :filtered_by_group, :filtered_by_group_type, :filtered_by_group_id, :filtered_by_type, :filtered_by_key, :custom_filter ) notification_index = load_notification_index(target, [:index_content], ) prepare_content_for(target, notification_index, ) # Render partial index render_partial_index(target, ) end |
#subscribe_subscription_path_for(subscription, params = {}) ⇒ String Also known as: subscribe_path_for
Needs any other better implementation
Returns subscribe_subscription_path for the target of specified subscription
246 247 248 249 250 251 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 246 def subscribe_subscription_path_for(subscription, params = {}) = params.dup .delete(:devise_default_routes) ? send("subscribe_#{routing_scope()}subscription_path", subscription, ) : send("subscribe_#{routing_scope()}#{subscription.target.to_resource_name}_subscription_path", subscription.target, subscription, ) end |
#subscribe_subscription_url_for(subscription, params = {}) ⇒ String Also known as: subscribe_url_for
Needs any other better implementation
Returns subscribe_subscription_url for the target of specified subscription
356 357 358 359 360 361 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 356 def subscribe_subscription_url_for(subscription, params = {}) = params.dup .delete(:devise_default_routes) ? send("subscribe_#{routing_scope()}subscription_url", subscription, ) : send("subscribe_#{routing_scope()}#{subscription.target.to_resource_name}_subscription_url", subscription.target, subscription, ) end |
#subscribe_to_email_subscription_path_for(subscription, params = {}) ⇒ String Also known as: subscribe_to_email_path_for
Needs any other better implementation
Returns subscribe_to_email_subscription_path for the target of specified subscription
274 275 276 277 278 279 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 274 def subscribe_to_email_subscription_path_for(subscription, params = {}) = params.dup .delete(:devise_default_routes) ? send("subscribe_to_email_#{routing_scope()}subscription_path", subscription, ) : send("subscribe_to_email_#{routing_scope()}#{subscription.target.to_resource_name}_subscription_path", subscription.target, subscription, ) end |
#subscribe_to_email_subscription_url_for(subscription, params = {}) ⇒ String Also known as: subscribe_to_email_url_for
Needs any other better implementation
Returns subscribe_to_email_subscription_url for the target of specified subscription
384 385 386 387 388 389 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 384 def subscribe_to_email_subscription_url_for(subscription, params = {}) = params.dup .delete(:devise_default_routes) ? send("subscribe_to_email_#{routing_scope()}subscription_url", subscription, ) : send("subscribe_to_email_#{routing_scope()}#{subscription.target.to_resource_name}_subscription_url", subscription.target, subscription, ) end |
#subscribe_to_optional_target_subscription_path_for(subscription, params = {}) ⇒ String Also known as: subscribe_to_optional_target_path_for
Needs any other better implementation
Returns subscribe_to_optional_target_subscription_path for the target of specified subscription
302 303 304 305 306 307 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 302 def subscribe_to_optional_target_subscription_path_for(subscription, params = {}) = params.dup .delete(:devise_default_routes) ? send("subscribe_to_optional_target_#{routing_scope()}subscription_path", subscription, ) : send("subscribe_to_optional_target_#{routing_scope()}#{subscription.target.to_resource_name}_subscription_path", subscription.target, subscription, ) end |
#subscribe_to_optional_target_subscription_url_for(subscription, params = {}) ⇒ String Also known as: subscribe_to_optional_target_url_for
Needs any other better implementation
Returns subscribe_to_optional_target_subscription_url for the target of specified subscription
412 413 414 415 416 417 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 412 def subscribe_to_optional_target_subscription_url_for(subscription, params = {}) = params.dup .delete(:devise_default_routes) ? send("subscribe_to_optional_target_#{routing_scope()}subscription_url", subscription, ) : send("subscribe_to_optional_target_#{routing_scope()}#{subscription.target.to_resource_name}_subscription_url", subscription.target, subscription, ) end |
#subscription_path_for(subscription, params = {}) ⇒ String
Needs any other better implementation
Returns subscription_path for the subscription
233 234 235 236 237 238 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 233 def subscription_path_for(subscription, params = {}) = params.dup .delete(:devise_default_routes) ? send("#{routing_scope()}subscription_path", subscription, ) : send("#{routing_scope()}#{subscription.target.to_resource_name}_subscription_path", subscription.target, subscription, ) end |
#subscription_url_for(subscription, params = {}) ⇒ String
Needs any other better implementation
Returns subscription_url for the subscription
343 344 345 346 347 348 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 343 def subscription_url_for(subscription, params = {}) = params.dup .delete(:devise_default_routes) ? send("#{routing_scope()}subscription_url", subscription, ) : send("#{routing_scope()}#{subscription.target.to_resource_name}_subscription_url", subscription.target, subscription, ) end |
#subscriptions_path_for(target, params = {}) ⇒ String
Needs any other better implementation
Returns subscriptions_path for the target
220 221 222 223 224 225 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 220 def subscriptions_path_for(target, params = {}) = params.dup .delete(:devise_default_routes) ? send("#{routing_scope()}subscriptions_path", ) : send("#{routing_scope()}#{target.to_resource_name}_subscriptions_path", target, ) end |
#subscriptions_url_for(target, params = {}) ⇒ String
Needs any other better implementation
Returns subscriptions_url for the target
330 331 332 333 334 335 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 330 def subscriptions_url_for(target, params = {}) = params.dup .delete(:devise_default_routes) ? send("#{routing_scope()}subscriptions_url", ) : send("#{routing_scope()}#{target.to_resource_name}_subscriptions_url", target, ) end |
#unsubscribe_subscription_path_for(subscription, params = {}) ⇒ String Also known as: unsubscribe_path_for
Needs any other better implementation
Returns unsubscribe_subscription_path for the target of specified subscription
260 261 262 263 264 265 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 260 def unsubscribe_subscription_path_for(subscription, params = {}) = params.dup .delete(:devise_default_routes) ? send("unsubscribe_#{routing_scope()}subscription_path", subscription, ) : send("unsubscribe_#{routing_scope()}#{subscription.target.to_resource_name}_subscription_path", subscription.target, subscription, ) end |
#unsubscribe_subscription_url_for(subscription, params = {}) ⇒ String Also known as: unsubscribe_url_for
Needs any other better implementation
Returns unsubscribe_subscription_url for the target of specified subscription
370 371 372 373 374 375 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 370 def unsubscribe_subscription_url_for(subscription, params = {}) = params.dup .delete(:devise_default_routes) ? send("unsubscribe_#{routing_scope()}subscription_url", subscription, ) : send("unsubscribe_#{routing_scope()}#{subscription.target.to_resource_name}_subscription_url", subscription.target, subscription, ) end |
#unsubscribe_to_email_subscription_path_for(subscription, params = {}) ⇒ String Also known as: unsubscribe_to_email_path_for
Needs any other better implementation
Returns unsubscribe_to_email_subscription_path for the target of specified subscription
288 289 290 291 292 293 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 288 def unsubscribe_to_email_subscription_path_for(subscription, params = {}) = params.dup .delete(:devise_default_routes) ? send("unsubscribe_to_email_#{routing_scope()}subscription_path", subscription, ) : send("unsubscribe_to_email_#{routing_scope()}#{subscription.target.to_resource_name}_subscription_path", subscription.target, subscription, ) end |
#unsubscribe_to_email_subscription_url_for(subscription, params = {}) ⇒ String Also known as: unsubscribe_to_email_url_for
Needs any other better implementation
Returns unsubscribe_to_email_subscription_url for the target of specified subscription
398 399 400 401 402 403 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 398 def unsubscribe_to_email_subscription_url_for(subscription, params = {}) = params.dup .delete(:devise_default_routes) ? send("unsubscribe_to_email_#{routing_scope()}subscription_url", subscription, ) : send("unsubscribe_to_email_#{routing_scope()}#{subscription.target.to_resource_name}_subscription_url", subscription.target, subscription, ) end |
#unsubscribe_to_optional_target_subscription_path_for(subscription, params = {}) ⇒ String Also known as: unsubscribe_to_optional_target_path_for
Needs any other better implementation
Returns unsubscribe_to_optional_target_subscription_path for the target of specified subscription
316 317 318 319 320 321 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 316 def unsubscribe_to_optional_target_subscription_path_for(subscription, params = {}) = params.dup .delete(:devise_default_routes) ? send("unsubscribe_to_optional_target_#{routing_scope()}subscription_path", subscription, ) : send("unsubscribe_to_optional_target_#{routing_scope()}#{subscription.target.to_resource_name}_subscription_path", subscription.target, subscription, ) end |
#unsubscribe_to_optional_target_subscription_url_for(subscription, params = {}) ⇒ String Also known as: unsubscribe_to_optional_target_url_for
Needs any other better implementation
Returns unsubscribe_to_optional_target_subscription_url for the target of specified subscription
426 427 428 429 430 431 |
# File 'lib/activity_notification/helpers/view_helpers.rb', line 426 def unsubscribe_to_optional_target_subscription_url_for(subscription, params = {}) = params.dup .delete(:devise_default_routes) ? send("unsubscribe_to_optional_target_#{routing_scope()}subscription_url", subscription, ) : send("unsubscribe_to_optional_target_#{routing_scope()}#{subscription.target.to_resource_name}_subscription_url", subscription.target, subscription, ) end |