ruby on rails - display array in text_field with semicolon delimeters -


i have ruby on rails form displays values of array stored in mongodb document.
in _form.html.erb file: <%=f.text_field :tags%>. displays tags array in text field separated spaces.
example in tags array have: ["recon","scanning","network"]. in text field on web page displayed "recon scanning network". i want display on web page "recon; scannnig; network" because have method in model split input semicolon:

def tags=(values)   values = values.split(";")   write_attribute(:tags, values.reject(&:blank?)) end 

with being displayed spaces, doesn't save database properly. it'll save array ["recon scanning network"] instead :\

so question is, how can arrays display in text_field seperated semicolons?

try

<%= f.text_field :tags, value: f.object.tags.join('; ') %> 

btw, converntion in ruby write variables , methods names in underscore notation.


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -