Module: Lesli::Interfaces::Controllers::Activities
- Defined in:
- app/controllers/lesli/interfaces/controllers/activities.rb
Instance Method Summary collapse
-
#create ⇒ Json
Json that contains wheter the creation of the activity was successful or not.
-
#index ⇒ Json
Json that contains a list of all activities related to a cloud_object.
-
#show ⇒ JSON
The json information about the selected activity.
Instance Method Details
#create ⇒ Json
Returns Json that contains wheter the creation of the activity was successful or not. If it is not successful, it returs an error message.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'app/controllers/lesli/interfaces/controllers/activities.rb', line 102 def create activity_model = activity_model() # If there is a custom activity model, it must be returned in this method cloud_object_model = activity_model.cloud_object_model set_cloud_object new_activity_params = activity_params.merge( user_creator: current_user, cloud_object: @cloud_object ) activity = activity_model.new(new_activity_params) if activity.save if block_given? yield(cloud_object, activity) else # Returning the 200 HTTP response respond_with_successful(activity) end else respond_with_error(activity.errors.) end end |
#index ⇒ Json
Returns Json that contains a list of all activities related to a cloud_object.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/lesli/interfaces/controllers/activities.rb', line 45 def index activity_model = activity_model() # If there is a custom activity model, it must be returned in this method cloud_object_model = activity_model.cloud_object_model translations_module = activity_model.name.split("::")[0].gsub("Cloud", "").underscore @activities = activity_model.index( current_user, params["#{cloud_object_model.name.demodulize.underscore}_id".to_sym], @query ) if block_given? yield(@activities) else respond_with_successful(@activities) end end |
#show ⇒ JSON
Returns The json information about the selected activity.
72 73 74 75 76 77 78 79 80 81 |
# File 'app/controllers/lesli/interfaces/controllers/activities.rb', line 72 def show set_activity return respond_with_not_found unless @activity if block_given? yield(@activity) else return respond_with_successful(@activity) end end |