Class: TentD::API::Posts::Update
- Inherits:
-
Middleware
- Object
- Middleware
- TentD::API::Posts::Update
- Defined in:
- lib/tentd/api/posts.rb
Instance Method Summary collapse
Methods inherited from Middleware
Methods included from Authorizable
#authorize_env!, #authorize_env?
Constructor Details
This class inherits a constructor from TentD::API::Middleware
Instance Method Details
#action(env) ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/tentd/api/posts.rb', line 214 def action(env) (env, :write_posts) if post = TentD::Model::Post.first(:id => env.params.post_id) version = post.latest_version(:fields => [:id]) post.update(env.params.data.slice(:content, :licenses, :mentions, :views)) if env.params..kind_of?(Array) Model::PostAttachment.all(:post_id => post.id).update(:post_id => nil, :post_version_id => version.id) end env.response = post end env end |