|
Hi Folks,
I was using the Authentication Plugin for Grails by Marc Palmer (http://grails.org/plugin/authentication) and wanted to add a phone number to the domain model. So I created the following class: class User { String login String password String email int status String phone static constraints = { } } So this is simply from the tutorial, but with one additional variable for the phone number of an User. When I write my User class into the Config.groovy and start my application, i get a runtime error: "Unable to save user details for ***". What should I do to make it a correct domain model? I hope, that you can help me. Thank you very much, great Plugin. Greetings, Ferhat --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
On 30 May 2012, at 16:39, Ferhat Beyaz wrote: > Hi Folks, > > I was using the Authentication Plugin for Grails by Marc Palmer > (http://grails.org/plugin/authentication) and wanted to add a phone > number to the domain model. So I created the following class: > > class User { > > String login > String password > String email > int status > > String phone > > static constraints = { > } > } > > So this is simply from the tutorial, but with one additional variable > for the phone number of an User. When I write my User class into the > Config.groovy and start my application, i get a runtime error: "Unable > to save user details for ***". What should I do to make it a correct > domain model? Hi, Your new field is probably failing to pass its implicit constraints when the plugin tries to save it. Marc ~ ~ ~ Marc Palmer Freelancer (Grails/Groovy/Java/UX) I offer commercial support for Grails plugins from as low as $50/mo. For details see: http://grailsrocks.com Blog: http://www.anyware.co.uk | Resumé: http://www.anyware.co.uk/marc Contributor @ http://grails.org | Founder @ http://noticelocal.com Developer @ http://weceem.org | Member @ http://spottymushroom.com Twitter: http://twitter.com/wangjammer5 --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by Ferhat Beyaz
On 30 May 2012, at 16:39, Ferhat Beyaz wrote: > Hi Folks, > > I was using the Authentication Plugin for Grails by Marc Palmer > (http://grails.org/plugin/authentication) and wanted to add a phone > number to the domain model. So I created the following class: > > class User { > > String login > String password > String email > int status > > String phone > > static constraints = { > } > } > > So this is simply from the tutorial, but with one additional variable > for the phone number of an User. When I write my User class into the > Config.groovy and start my application, i get a runtime error: "Unable > to save user details for ***". What should I do to make it a correct > domain model? Hi, Your new field is probably failing to pass its implicit constraints when the plugin tries to save it. Marc ~ ~ ~ Marc Palmer Freelancer (Grails/Groovy/Java/UX) I offer commercial support for Grails plugins from as low as $50/mo. For details see: http://grailsrocks.com Blog: http://www.anyware.co.uk | Resumé: http://www.anyware.co.uk/marc Contributor @ http://grails.org | Founder @ http://noticelocal.com Developer @ http://weceem.org | Member @ http://spottymushroom.com Twitter: http://twitter.com/wangjammer5 --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by Marc Palmer Local
Hi Marc,
Sorry, but what implicit constraints do you mean? I actually didn't know, that there are any implicit constraints, so I googled it, but found nothing. 2012/5/30 Marc Palmer <[hidden email]>: > > On 30 May 2012, at 16:39, Ferhat Beyaz wrote: > >> Hi Folks, >> >> I was using the Authentication Plugin for Grails by Marc Palmer >> (http://grails.org/plugin/authentication) and wanted to add a phone >> number to the domain model. So I created the following class: >> >> class User { >> >> String login >> String password >> String email >> int status >> >> String phone >> >> static constraints = { >> } >> } >> >> So this is simply from the tutorial, but with one additional variable >> for the phone number of an User. When I write my User class into the >> Config.groovy and start my application, i get a runtime error: "Unable >> to save user details for ***". What should I do to make it a correct >> domain model? > > > Hi, > > Your new field is probably failing to pass its implicit constraints when the plugin tries to save it. > > Marc > > ~ ~ ~ > Marc Palmer > Freelancer (Grails/Groovy/Java/UX) > > I offer commercial support for Grails plugins from as low as $50/mo. > For details see: http://grailsrocks.com > > Blog: http://www.anyware.co.uk | Resumé: http://www.anyware.co.uk/marc > Contributor @ http://grails.org | Founder @ http://noticelocal.com > Developer @ http://weceem.org | Member @ http://spottymushroom.com > Twitter: http://twitter.com/wangjammer5 > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
On 30 May 2012, at 16:52, Ferhat Beyaz wrote: > Hi Marc, > > > > Sorry, but what implicit constraints do you mean? I actually didn't > know, that there are any implicit constraints, so I googled it, but > found nothing. Well it "should" work out of the box without your extra field. Does it? When adding a simple string field no extra constraints should be added, and they should be nullable by default. However, are you 100% sure the email address value you are supplying is valid? Marc ~ ~ ~ Marc Palmer Freelancer (Grails/Groovy/Java/UX) I offer commercial support for Grails plugins from as low as $50/mo. For details see: http://grailsrocks.com Blog: http://www.anyware.co.uk | Resumé: http://www.anyware.co.uk/marc Contributor @ http://grails.org | Founder @ http://noticelocal.com Developer @ http://weceem.org | Member @ http://spottymushroom.com Twitter: http://twitter.com/wangjammer5 --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Without the extra field it works correctly out of the box.
When I add it, it doesn't work anymore and any registrations ends in a runtime error: "Unable to save user details for ***" Im sure, I use the same login, e-mail address and pwd. But when I add the extra field, this doesn't work anymore. Do I have to make a field in the registration form, where the user puts in his phone number? Don't think so. My class looks like this. Nothing special: class User { String login String password String email int status String phone static constraints = { } } 2012/5/30 Marc Palmer <[hidden email]>: > > On 30 May 2012, at 16:52, Ferhat Beyaz wrote: > >> Hi Marc, >> >> >> >> Sorry, but what implicit constraints do you mean? I actually didn't >> know, that there are any implicit constraints, so I googled it, but >> found nothing. > > > Well it "should" work out of the box without your extra field. Does it? > > When adding a simple string field no extra constraints should be added, and they should be nullable by default. > > However, are you 100% sure the email address value you are supplying is valid? > > Marc > > ~ ~ ~ > Marc Palmer > Freelancer (Grails/Groovy/Java/UX) > > I offer commercial support for Grails plugins from as low as $50/mo. > For details see: http://grailsrocks.com > > Blog: http://www.anyware.co.uk | Resumé: http://www.anyware.co.uk/marc > Contributor @ http://grails.org | Founder @ http://noticelocal.com > Developer @ http://weceem.org | Member @ http://spottymushroom.com > Twitter: http://twitter.com/wangjammer5 > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Or do I have to tell the plugin in another way what to do with the
phone number field? 2012/5/30 Ferhat Beyaz <[hidden email]>: > Without the extra field it works correctly out of the box. > > When I add it, it doesn't work anymore and any registrations ends in a > runtime error: "Unable to save user details for ***" > > Im sure, I use the same login, e-mail address and pwd. But when I add > the extra field, this doesn't work anymore. Do I have to make a field > in the registration form, where the user puts in his phone number? > Don't think so. > > My class looks like this. Nothing special: > > class User { > > String login > String password > String email > int status > > String phone > > static constraints = { > } > } > > > 2012/5/30 Marc Palmer <[hidden email]>: >> >> On 30 May 2012, at 16:52, Ferhat Beyaz wrote: >> >>> Hi Marc, >>> >>> >>> >>> Sorry, but what implicit constraints do you mean? I actually didn't >>> know, that there are any implicit constraints, so I googled it, but >>> found nothing. >> >> >> Well it "should" work out of the box without your extra field. Does it? >> >> When adding a simple string field no extra constraints should be added, and they should be nullable by default. >> >> However, are you 100% sure the email address value you are supplying is valid? >> >> Marc >> >> ~ ~ ~ >> Marc Palmer >> Freelancer (Grails/Groovy/Java/UX) >> >> I offer commercial support for Grails plugins from as low as $50/mo. >> For details see: http://grailsrocks.com >> >> Blog: http://www.anyware.co.uk | Resumé: http://www.anyware.co.uk/marc >> Contributor @ http://grails.org | Founder @ http://noticelocal.com >> Developer @ http://weceem.org | Member @ http://spottymushroom.com >> Twitter: http://twitter.com/wangjammer5 >> >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
On 30 May 2012, at 17:14, Ferhat Beyaz wrote: > Or do I have to tell the plugin in another way what to do with the > phone number field? No, it doesn't care about that. Please confirm: 1) that it works with your custom domain class, but without the "phone" property. 2) That you are honouring this from the docs: int status // must be set to AuthenticationService.STATUS_NEW at init i.e. your code must default status to that value. If not, I suggest you grab a debugger and trace into the plugin source. Kind regards Marc ~ ~ ~ Marc Palmer Freelancer (Grails/Groovy/Java/UX) I offer commercial support for Grails plugins from as low as $50/mo. For details see: http://grailsrocks.com Blog: http://www.anyware.co.uk | Resumé: http://www.anyware.co.uk/marc Contributor @ http://grails.org | Founder @ http://noticelocal.com Developer @ http://weceem.org | Member @ http://spottymushroom.com Twitter: http://twitter.com/wangjammer5 --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by Ferhat Beyaz
On 30/05/2012 17:12, Ferhat Beyaz wrote:
> Im sure, I use the same login, e-mail address and pwd. But when I add > the extra field, this doesn't work anymore. Do I have to make a field > in the registration form, where the user puts in his phone number? By default all properties in GORM are non-nullable. If your registration form doesn't have a phone number field then the phone property on your newly-created domain object will be null, which fails validation. If there *is* a form field then the property will not be null. It might be the empty string if the user chooses not to fill the field in but it won't be null. So if you want the phone number to be optional you should give it a nullable:true constraint. Ian -- Ian Roberts | Department of Computer Science [hidden email] | University of Sheffield, UK --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
This was the problem. I created a phone field, the implicit constraint
was, that it couldn't be nullable. On the signup form I didn't ask for a phone number, so it was null. Now I added the constraint nullable:true and all works fine. :) Thank you, very much. Very clear and direct help. Keep on the good work. Greetings 2012/5/30 Ian Roberts <[hidden email]>: > On 30/05/2012 17:12, Ferhat Beyaz wrote: >> Im sure, I use the same login, e-mail address and pwd. But when I add >> the extra field, this doesn't work anymore. Do I have to make a field >> in the registration form, where the user puts in his phone number? > > By default all properties in GORM are non-nullable. > > If your registration form doesn't have a phone number field then the > phone property on your newly-created domain object will be null, which > fails validation. If there *is* a form field then the property will not > be null. It might be the empty string if the user chooses not to fill > the field in but it won't be null. > > So if you want the phone number to be optional you should give it a > nullable:true constraint. > > Ian > > -- > Ian Roberts | Department of Computer Science > [hidden email] | University of Sheffield, UK > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
This post has NOT been accepted by the mailing list yet.
Does anyone has an example of a User class using the Authentication Plugin for Grails by Marc Palmer
> (http://grails.org/plugin/authentication). I am pretty new on Grails and I do not understand how to use the plugin together with my User class. Thanks a lot! E. |
| Powered by Nabble | Edit this page |
