<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi Vincent,
<div class=""><br class="">
</div>
<div class="">Here is the correct way of doing this:</div>
<div class=""><br class="">
</div>
<div class="">pry(main)> user = LinkedData::Models::User.where(username: 'admin').first</div>
<div class="">pry(main)> user.bring_remaining</div>
<div class="">pry(main)> user.password="hello12345"</div>
<div class="">
<div class="">pry(main)> user.valid?</div>
</div>
<div class="">
<div class="">pry(main)> user.save</div>
</div>
<div class=""><br class="">
</div>
<div class="">Hope this helps!</div>
<div class=""><br class="">
</div>
<div class="">Michael</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Mar 10, 2016, at 06:32, Vincent Emonet <<a href="mailto:vincent.emonet@lirmm.fr" class="">vincent.emonet@lirmm.fr</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div bgcolor="#FFFFFF" text="#000000" class="">Hi,<br class="">
<br class="">
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)<br class="">
<br class="">
It seems that it can be done easily using the "password=" method of LinkedData::Models::User<br class="">
<br class="">
<a href="https://github.com/sifrproject/ontologies_linked_data/blob/master/lib/ontologies_linked_data/models/users/user.rb#L83" class=""></a><a class="moz-txt-link-freetext" href="https://github.com/sifrproject/ontologies_linked_data/blob/master/lib/ontologies_linked_data/models/users/user.rb#L83">https://github.com/sifrproject/ontologies_linked_data/blob/master/lib/ontologies_linked_data/models/users/user.rb#L83</a><br class="">
<br class="">
<ul class="">
<li class="">Using the VA console: </li></ul>
bin/ncbo_cron --console<br class="">
<br class="">
<ul class="">
<li class="">Trying to change the user fails: </li></ul>
<br class="">
pry(main)> user = LinkedData::Models::User.find("admin")<br class="">
    .include(LinkedData::Models::User.attributes(:all))<br class="">
    .first<br class="">
<br class="">
This command is working fine and returning<br class="">
<blockquote type="cite" class="">=> #<LinkedData::Models::User:0x007f37437a7660<br class="">
 @aggregates=nil,<br class="">
 @email=<a class="moz-txt-link-rfc2396E" href="mailto:admin@example.org">"admin@example.org"</a>,<br class="">
 @id=#<RDF::URI:0x3f9ba2538acc(<a class="moz-txt-link-freetext" href="http://data.bioontology.org/users/admin">http://data.bioontology.org/users/admin</a>)>,<br class="">
 @loaded_attributes=#<Set: {:username, :email, :passwordHash}>,<br class="">
 @modified_attributes=#<Set: {}>,<br class="">
 @passwordHash="$2a$10$EHPrU.dR9cmWRq4M5G6W4eIOZGtHCdRjzJMhZaux8lHFz5fP.SlLq",<br class="">
 @persistent=true,<br class="">
 @previous_values=nil,<br class="">
 @unmapped=nil,<br class="">
 @username="admin"></blockquote>
<br class="">
But if I directly call back user I got errors (related to existence of attributes):<br class="">
<br class="">
pry(main)> user<br class="">
<blockquote type="cite" class="">=> #<LinkedData::Models::User:0x007f3744fe99f8<br class="">
 @aggregates=nil,<br class="">
 @errors=<br class="">
  {:username=>{:existence=>"`username` value cannot be nil"},<br class="">
   :email=>{:existence=>"`email` value cannot be nil"},<br class="">
   :passwordHash=>{:existence=>"`passwordHash` value cannot be nil"}},<br class="">
 @id=#<RDF::URI:0x3f9ba2538acc(<a class="moz-txt-link-freetext" href="http://data.bioontology.org/users/admin">http://data.bioontology.org/users/admin</a>)>,<br class="">
 @lastName="teest",<br class="">
 @loaded_attributes=#<Set: {:lastName, :username}>,<br class="">
 @modified_attributes=#<Set: {:lastName}>,<br class="">
 @persistent=true,<br class="">
 @previous_values=nil,<br class="">
 @unmapped=nil><br class="">
[47] pry(main)> </blockquote>
<br class="">
<br class="">
This is preventing me from doing "user.valid?" and "user.save"<br class="">
<br class="">
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.<br class="">
<br class="">
<br class="">
Have a good day,<br class="">
<br class="">
Vincent Emonet<br class="">
<br class="">
<br class="">
<br class="">
</div>
_______________________________________________<br class="">
bioontology-support mailing list<br class="">
<a href="mailto:bioontology-support@lists.stanford.edu" class="">bioontology-support@lists.stanford.edu</a><br class="">
https://mailman.stanford.edu/mailman/listinfo/bioontology-support<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>