jeudi 2 avril 2015

Is it bad to save data as ActionController::Parameters in a postgres DB with Rails?

Here is the situation. I use facebook login and want to save the array of friends into my rails server with a postgres database.


The params coming in for the fb_friends are:



"fb_friends"=>[{"id"=>"1381984758791468", "name"=>"ios ipod"}]


Api controller strong parameters: user_params has fb_friends: [:id, :name]


In the User model, I serialize fb_friends.



serialize :fb_friends


All this work but I notice that the class type for my fb_friend is ActionController::Parameters and it behaves like a Hash. Is this a bad thing?


In Rails console,



u.fb_friends.first.class
=> ActionController::Parameters

u.fb_friends.first[:id]
=> "1381984758791468"

u.fb_friends.first[:name]
=> "ios ipod"

Aucun commentaire:

Enregistrer un commentaire