5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 04:36:21 +00:00

refactor: asignar atributos

This commit is contained in:
f 2024-04-17 18:06:56 -03:00
parent 42e9d5fd66
commit ce3ff1bdab
No known key found for this signature in database

View file

@ -10,13 +10,14 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
self.post = site.posts(lang: locale) self.post = site.posts(lang: locale)
.build(layout: layout) .build(layout: layout)
post.usuaries << usuarie post.usuaries << usuarie
params[:post][:draft] = true if site.invitade? usuarie post.draft.value = true if site.invitade? usuarie
post.assign_attributes(post_params)
params.require(:post).permit(:slug).tap do |p| params.require(:post).permit(:slug).tap do |p|
post.slug.value = p[:slug] if p[:slug].present? post.slug.value = p[:slug] if p[:slug].present?
end end
commit(action: :created, add: update_related_posts) if post.update(post_params) commit(action: :created, add: update_related_posts) if post.save
update_site_license! update_site_license!