Model.new(nil) blow up?

1 view
Skip to first unread message

trung

unread,
Nov 24, 2009, 2:48:18 AM11/24/09
to DataMapper
is this intentional?

In rails and active record land. We can do this @model = Model.new
(params[:model]) and never have to worry checking for nil.

Now I have to do this @model = Model.new(params[:model] || {})

Thanks.

Dan Kubb (dkubb)

unread,
Nov 24, 2009, 10:18:07 PM11/24/09
to DataMapper
> is this intentional?

Not in this case. In other cases we've been somewhat strict,
especially in the DSL layer where it's important to specify behaviour
explicitly, but something like this we would generally want to handle
in DM.

> In rails and active record land. We can do this @model = Model.new
> (params[:model]) and never have to worry checking for nil.
>
> Now I have to do this @model = Model.new(params[:model] || {})

Submit a ticket and I'll fix that:

http://is.gd/aa86

--

Dan
(dkubb)

Ashley Moran

unread,
Nov 25, 2009, 5:27:36 AM11/25/09
to datam...@googlegroups.com

On Nov 25, 2009, at 3:18 am, Dan Kubb (dkubb) wrote:

>> is this intentional?
>
> Not in this case. In other cases we've been somewhat strict,
> especially in the DSL layer where it's important to specify behaviour
> explicitly, but something like this we would generally want to handle
> in DM.

I'm not sure. Devil's advocate: The case when no parameters are supplied feels to me like something that should be handled at the boundary of the application ... otherwise, isn't there a risk of user interface logic filtering down through the app?

I'd be interested to hear opinions.

Ashley

--
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran

Reply all
Reply to author
Forward
0 new messages