ruby on rails - How to create input fields for a hash storing multiple values in a database column? -


i'm trying store multiple values using hash in database column "text" in object called overlays.

so calling looks overlay.text

there multiple values want store in text column, such as..

• preheadline • bullet1 • bullet2 • bullet3

i'm serializing text column in model

class overlay < activerecord::base   belongs_to :user   has_many :contacts, as: :contactable   serialize :text 

then, in form creating model, i've tried creating input field "bullet1", it's not storing value.

    <div class="form-group">       <h4 class="col-xs-12 field-title">bullet 1</h4>       <div class="col-md-12">         <input type="text" name="overlay[text][bullet1]"     placeholder="bullet point text here" class="form-control input-lg" value="<%= @overlay.text[:bullet1] if defined? @overylay.text , @overlay.text[:bullet1].present? %>" />       </div>     </div> 

and i'm trying value display so..

<span style="display: block; margin-top: -15px; margin-left: 25px;"><% if @overlay.text , @overlay.text[:bullet1].present? %><%= @overlay.text[:bullet1] %><% else %>this should not show<% end %>           </span> 

so far, i've had no luck getting value "bullet1" save in text database column.

any thoughts on why?


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -