scinote-web/app/serializers/repository_column_serializer.rb

28 lines
792 B
Ruby
Raw Normal View History

2019-10-21 19:01:31 +08:00
# frozen_string_literal: true
class RepositoryColumnSerializer < ActiveModel::Serializer
include Rails.application.routes.url_helpers
2019-10-22 19:20:05 +08:00
attributes :id, :name, :message, :edit_html_url, :update_url, :destroy_html_url
2019-10-21 19:01:31 +08:00
def message
2019-10-25 16:39:12 +08:00
if instance_options[:creating]
I18n.t('libraries.repository_columns.create.success_flash', name: object.name)
elsif instance_options[:editing]
I18n.t('libraries.repository_columns.update.success_flash', name: object.name)
end
2019-10-21 19:01:31 +08:00
end
2019-10-22 19:20:05 +08:00
def edit_html_url
2019-10-21 19:01:31 +08:00
edit_repository_repository_column_path(object.repository, object)
end
def update_url
repository_repository_columns_text_column_path(object.repository, object)
end
def destroy_html_url
repository_columns_destroy_html_path(object.repository, object)
end
end