Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[bioontology-support] Editing models

Vincent Emonet vincent.emonet at lirmm.fr
Thu Mar 10 06:32:16 PST 2016


Hi,

I am trying to edit a User to change its password (to quickly change the 
"admin" password without having to send a reset email and all)

It seems that it can be done easily using the "password=" method of 
LinkedData::Models::User

https://github.com/sifrproject/ontologies_linked_data/blob/master/lib/ontologies_linked_data/models/users/user.rb#L83

  * Using the VA console:

bin/ncbo_cron --console

  * Trying to change the user fails:


pry(main)> user = LinkedData::Models::User.find("admin")
     .include(LinkedData::Models::User.attributes(:all))
     .first

This command is working fine and returning
> => #<LinkedData::Models::User:0x007f37437a7660
>  @aggregates=nil,
>  @email="admin at example.org",
>  @id=#<RDF::URI:0x3f9ba2538acc(http://data.bioontology.org/users/admin)>,
>  @loaded_attributes=#<Set: {:username, :email, :passwordHash}>,
>  @modified_attributes=#<Set: {}>,
>  @passwordHash="$2a$10$EHPrU.dR9cmWRq4M5G6W4eIOZGtHCdRjzJMhZaux8lHFz5fP.SlLq",
>  @persistent=true,
>  @previous_values=nil,
>  @unmapped=nil,
>  @username="admin">

But if I directly call back user I got errors (related to existence of 
attributes):

pry(main)> user
> => #<LinkedData::Models::User:0x007f3744fe99f8
>  @aggregates=nil,
>  @errors=
>   {:username=>{:existence=>"`username` value cannot be nil"},
>    :email=>{:existence=>"`email` value cannot be nil"},
>    :passwordHash=>{:existence=>"`passwordHash` value cannot be nil"}},
>  @id=#<RDF::URI:0x3f9ba2538acc(http://data.bioontology.org/users/admin)>,
>  @lastName="teest",
>  @loaded_attributes=#<Set: {:lastName, :username}>,
>  @modified_attributes=#<Set: {:lastName}>,
>  @persistent=true,
>  @previous_values=nil,
>  @unmapped=nil>
> [47] pry(main)> 


This is preventing me from doing "user.valid?" and "user.save"

Why are username, email and passwordHash considered as nil when I call 
back user (we can see their values when we call it the first time)? 
Seems like the object isn't consistent.


Have a good day,

Vincent Emonet



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/bioontology-support/attachments/20160310/77345b57/attachment.html>


More information about the bioontology-support mailing list