You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails: Talk
After all to bypass this I needed to call the data in database
directly without involvement of "serialize" AR method.
YAML::load(User.first.roles_before_type_cast)
And now test environment also directly parses the data and give me
correct roles Array.
On 9 Mar, 19:24, Marcin Seroczyński <mar...@seroczynski.net> wrote:
> Hello,
>
> I've got a problem with deserialization of AR "serialize" method
> (http://apidock.com/rails/ActiveRecord/Base/serialize/class) in my
> tests.
> It just gives me pure String instead of my data Array.
>
> Example:
> User > AR::Base
> serialize:roles, Array
> end
>
> Console:
> u = User.new
> u.roles = ["admin", "support"]
> u.save
> # => true
>
> User.first.roles
> # => ["admin", "support"]
>
> In test environment:
> User.first.roles
> # => "--- \n- admin\n"
>
> it is a String. It seems that YAMLserializeis not working there but