Rails is great and most things just work easily. However, I've never
been able to get a definite answer on whether one should do,
validates :parent, :presence => true
or,
validates :parent_id, :presence => true
given,
class Parent
end
class Child
belongs_to :parent
end
I've always thought
On 4 February 2011 20:30, Paul wrote:
> I've always thought that validating the :parent (and not the foreign
> key) is the *more* correct thing to do ... but I don't understand why
> Rails does not reset the parent association when the parent_id is
> changed as demonstrated here,
>
> Any thoughts?
On 4 February 2011 20:36, Michael Pavling wrote:
> That's my preference anyhoo...
oops! This is rails-core list... take it over to "talk"
apologies...
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email t
On Feb 4, 2011, at 3:30 PM, Paul wrote:
> Rails is great and most things just work easily. However, I've never
> been able to get a definite answer on whether one should do,
>
> validates :parent, :presence => true
>
> or,
>
> validates :parent_id, :presence => true
>
> given,
>
> class Paren
Hey,
In edge rails there is a mechanism for checking whether the loaded
association target is "stale" - so if you do record.foo_id = x, then
record.foo will load the target afresh.
I'm not sure whether it necessarily works with validation like this, but
hopefully it does. [I haven't tried.]
Just
On 5/02/2011, at 9:30 AM, Paul wrote:
> Rails is great and most things just work easily. However, I've never
> been able to get a definite answer on whether one should do,
>
> validates :parent, :presence => true
>
> or,
>
> validates :parent_id, :presence => true
>
Validate the object, not the
On Fri, Feb 4, 2011 at 9:36 PM, Michael Pavling wrote:
> On 4 February 2011 20:30, Paul wrote:
>> I've always thought that validating the :parent (and not the foreign
>> key) is the *more* correct thing to do
>> I've never
>> been able to get a definite answer on whether one should do,
>>
>> vali
On Sun, Feb 6, 2011 at 2:10 PM, Rainer Frey wrote:
> Unfortunately the Rails Guide on Active Record Validation and
> Callbacks says (Section 3.9):
> "If you want to be sure that an association is present, you’ll need to
> test whether the foreign key used to map the association is present,
> and
On Mon, Feb 7, 2011 at 11:58 AM, Xavier Noria wrote:
> On Sun, Feb 6, 2011 at 2:10 PM, Rainer Frey wrote:
>
>> Unfortunately the Rails Guide on Active Record Validation and
>> Callbacks says (Section 3.9):
>> "If you want to be sure that an association is present, you’ll need to
>> test whether t
On Mon, 2011-02-07 at 14:28 +0100, Rainer Frey wrote:
> On Mon, Feb 7, 2011 at 11:58 AM, Xavier Noria wrote:
> > On Sun, Feb 6, 2011 at 2:10 PM, Rainer Frey wrote:
> >
> >> Unfortunately the Rails Guide on Active Record Validation and
> >> Callbacks says (Section 3.9):
> >> "If you want to be sur
On Mon, Feb 7, 2011 at 2:28 PM, Rainer Frey wrote:
> But this thread seems to suggest one should simply validate the
> association attribute instead. Is that not sufficient then?
You can't still be sure the association is valid, because the
associated object is cached if previously fetched, and
Hey,
On Mon, 2011-02-07 at 15:22 +0100, Xavier Noria wrote:
> On Mon, Feb 7, 2011 at 2:28 PM, Rainer Frey wrote:
>
> > But this thread seems to suggest one should simply validate the
> > association attribute instead. Is that not sufficient then?
>
> You can't still be sure the association is v
12 matches
Mail list logo