ruby - Save Rails array with outer quotes -


is possible save following array without outer quotes? or possible access array without outer quotes?

e.hours = "5:30am", "6:00am", "6:30am" # => ["5:30am", "6:00am", "6:30am"]  e.save    (0.2ms)  begin transaction   sql (1.6ms)  update "brands" set "hours" = ?, "updated_at" = ? "brands"."id" = ?  [["hours", "[\"5:30am\", \"6:00am\", \"6:30am\"]"], ["updated_at", "2015-09-30 00:35:25.117927"], ["id", 1]]    (6.8ms)  commit transaction # => true  e # => #<brand id: 1, name: "starbucks", created_at: "2015-09-23 22:59:08", updated_at: "2015-09-30 00:35:25", hours: "[\"5:30am\", \"6:00am\", \"6:30am\">  

this migration looks like:

add_column :brands, :hours, :string, array: true, default: [] 

when try access array in controller, returns array outer quotes:

[1] pry(#<orderscontroller>)> @delivery_hours # => "[\"5:30am\", \"6:00am\", \"6:30am\"]" 

in order.rb file, add this:

serialize :hours, array 

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' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -