forked from e621ng/e621ng
[Mascots] Fix handling of app names with spaces in them
Use comma as a separator instead. Closes #551
This commit is contained in:
parent
2624a0f706
commit
4a26251e77
@ -322,9 +322,9 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
# The `<attribute>=` setter parses strings into an array using the
|
||||
# `parse` regex. The resulting strings can be converted to another type
|
||||
# with the `cast` option.
|
||||
def array_attribute(name, parse: /[^[:space:]]+/, cast: :itself)
|
||||
def array_attribute(name, parse: /[^[:space:]]+/, join_character: " ", cast: :itself)
|
||||
define_method "#{name}_string" do
|
||||
send(name).join(" ")
|
||||
send(name).join(join_character)
|
||||
end
|
||||
|
||||
define_method "#{name}_string=" do |value|
|
||||
|
@ -1,7 +1,7 @@
|
||||
class Mascot < ApplicationRecord
|
||||
belongs_to_creator
|
||||
|
||||
array_attribute :available_on
|
||||
array_attribute :available_on, parse: /[^,]+/, join_character: ","
|
||||
attr_accessor :mascot_file
|
||||
|
||||
validates :display_name, :background_color, :artist_url, :artist_name, presence: true
|
||||
|
@ -5,7 +5,7 @@
|
||||
<%= f.input :background_color %>
|
||||
<%= f.input :artist_url %>
|
||||
<%= f.input :artist_name %>
|
||||
<%= f.input :available_on_string, label: "Available on" %>
|
||||
<%= f.input :available_on_string, label: "Available on", hint: "Separated by a comma, don't include spaces before/after" %>
|
||||
<%= f.input :active %>
|
||||
<%= f.submit %>
|
||||
<% end %>
|
||||
|
Loading…
Reference in New Issue
Block a user