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

Michael Dorf mdorf at stanford.edu
Thu Mar 10 11:28:27 PST 2016


Hi Vincent,

Here is the correct way of doing this:

pry(main)> user = LinkedData::Models::User.where(username: 'admin').first
pry(main)> user.bring_remaining
pry(main)> user.password="hello12345"
pry(main)> user.valid?
pry(main)> user.save

Hope this helps!

Michael


On Mar 10, 2016, at 06:32, Vincent Emonet <vincent.emonet at lirmm.fr<mailto:vincent.emonet at lirmm.fr>> wrote:

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>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"<mailto: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



_______________________________________________
bioontology-support mailing list
bioontology-support at lists.stanford.edu<mailto:bioontology-support at lists.stanford.edu>
https://mailman.stanford.edu/mailman/listinfo/bioontology-support

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


More information about the bioontology-support mailing list