[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Jim Burgess
> I recommend this setup for date entry since it does help a little with > the input sanitizing: When you use a Select tag, the user input options > are known values and it allows you to be much more aggressive and > unforgiving with your input validation. Text box input requires some > fuzzy ac

[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Aaron Brown
p_W wrote: > So this won't fix the problem of user input outside the browser, but > what about implementing the date fields as 's instead of text > fields? You will still have to sanitize the data but at least you > have defined the format in which the user inputs it through the > browser. I rec

[Rails] Re: Where to put additional code for model.

2009-05-12 Thread p_W
So this won't fix the problem of user input outside the browser, but what about implementing the date fields as 's instead of text fields? You will still have to sanitize the data but at least you have defined the format in which the user inputs it through the browser. On May 12, 10:09 am, Ar Ch

[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Ar Chron
Jim Burgess wrote: > > At the moment it is sitting at the top of my model, but the method is > quite long and this looks a bit ugly / cluttered. > Sometimes code is ugly no matter what... ;) I remember having to account for the difference between little-endian veruss big-endian architectures

[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Jim Burgess
Ok, cheers for that. I guess I will have to rethink my approach. In defense of my current method, to make sure the date field doesn't accept incorrect input I use ruby's 'Date.strptime' to parse the string as a date. If it works then everything is ok, if it throws an error then I catch this and

[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Michael Schuerig
On Tuesday 12 May 2009, Jim Burgess wrote: > Hi Michael, > Thanks for the reply. > > >> "dd-mm-" (including hyphens). > > > > Why? IMHO, the best you can do is have a look at how date_select > > works, you'll notice that it already does what you're trying to do. > > But isn't date_select reall

[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Jim Burgess
Hi Michael, Thanks for the reply. >> "dd-mm-" (including hyphens). > Why? IMHO, the best you can do is have a look at how date_select works, > you'll notice that it already does what you're trying to do. But isn't date_select really feeble? For example it is very easy to make the whole appl

[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Michael Schuerig
On Tuesday 12 May 2009, Jim Burgess wrote: > Hi, > > Thanks very much for the replies. > I will follow Michael's advice and stick it in a module. > > > I hope you know what you're doing. > > Probably nowhere near as much as I should > > > What if one of the strings is > > %x{echo gotcha} > > or wo

[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Jim Burgess
Hi, Thanks very much for the replies. I will follow Michael's advice and stick it in a module. > I hope you know what you're doing. Probably nowhere near as much as I should > What if one of the strings is > %x{echo gotcha} > or worse? It's a date input which is mapped. In the model the field

[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Michael Schuerig
On Tuesday 12 May 2009, Jim Burgess wrote: > Hi, > I have written a method to map three 'virtual' fields in my form to > one 'proper' field in my model. > It looks like this: > > class Class > def map_three_fields(var1, var2, var3) > string_val = "...do stuff..." >self.class_eval string_

[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Colin Law
2009/5/12 Jim Burgess > > Hi, > I have written a method to map three 'virtual' fields in my form to one > 'proper' field in my model. > It looks like this: > > class Class > def map_three_fields(var1, var2, var3) >string_val = "...do stuff..." > self.class_eval string_val > end > end > >

[Rails] Re: Where to put additional code for model.

2009-05-12 Thread 7stud --
Jim Burgess wrote: > Hi, > I have written a method to map three 'virtual' fields in my form to one > 'proper' field in my model. > It looks like this: > > class Class > def map_three_fields(var1, var2, var3) > string_val = "...do stuff..." >self.class_eval string_val > end > end > >