Class: MessagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- MessagesController
- Includes:
- PageAndSortHelper, PageAndSortHelper::Controller
- Defined in:
- lib/generators/kitestrings/message_templates/messages_controller.rb
Instance Method Summary collapse
- #index ⇒ Object
-
#show ⇒ Object
this one controller action has two totally different functions:.
Methods included from PageAndSortHelper::Controller
Methods included from PageAndSortHelper
#sort_column, #sort_direction, #sortable_title
Instance Method Details
#index ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/generators/kitestrings/message_templates/messages_controller.rb', line 15 def index @messages = case when @user @user. when can?(:index_all, Message) Message else current_user. end @messages = page_and_sort(@messages, default_sort: :created_at, default_direction: :desc) end |
#show ⇒ Object
this one controller action has two totally different functions:
-
/users/1/messages/3 => show the message content
-
/messages/3 => mark the message clicked at time and redirect to the link in the message.
33 34 35 36 37 38 39 40 |
# File 'lib/generators/kitestrings/message_templates/messages_controller.rb', line 33 def show if @user # show else @message.update_column(:clicked_at, Time.now) if current_user == @message.user redirect_to @message.link end end |