Rails 3 RC and the 'returning' method in adapters.rb

瀏覽次數:55 次
跳到第一則未讀訊息

Tim

未讀,
2010年7月29日 下午3:17:302010/7/29
收件者:Sunspot
It looks like the 'returning' method, which is used on line 75 of
adapters.rb, has been removed in Rails 3.0.0.rc:

http://github.com/rails/rails/commit/b0b9bf320409b66c6c6b680371aca590297cd4cc

It is supposed to be replaced by a new Ruby 1.9 function 'tap', which
supposedly does the same thing. But when I replace 'returning' with
'tap' in adapters.rb, I get an error about arguments (1 for 0), and
then when I delete the brackets and parentheses after the function I
get an "undefined method 'merge'" error on line 67.

That about reaches the limit of my understanding of the problem. Any
suggestions for how to further modify adapters.rb to use tap instead
of returning?

Thanks!

Mat Brown

未讀,
2010年7月29日 下午3:21:042010/7/29
收件者:ruby-s...@googlegroups.com
You could just not use either -- #returning and #tap are both
basically semantic sugar for those who prefer indentation over
assigning local variables...

> --
> You received this message because you are subscribed to the Google Groups "Sunspot" group.
> To post to this group, send email to ruby-s...@googlegroups.com.
> To unsubscribe from this group, send email to ruby-sunspot...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ruby-sunspot?hl=en.
>
>

Tim

未讀,
2010年7月29日 下午3:44:132010/7/29
收件者:Sunspot
That is an excellent point.

I've got it working now, and my adapters.rb file looks like this:

def load(id)
options_for_find
@clazz.first(
:conditions => { @clazz.primary_key => id.to_i}
)
end

def load_all(ids)
options_for_find
@clazz.all(
:conditions => { @clazz.primary_key => ids.map { |id|
id.to_i }}
)
end

private

def options_for_find
options[:include] = @include unless @include.blank?
options[:select] = @select unless @select.blank?
end


Thanks again for your help!


On Jul 29, 3:21 pm, Mat Brown <m...@patch.com> wrote:
> You could just not use either -- #returning and #tap are both
> basically semantic sugar for those who prefer indentation over
> assigning local variables...
>
>
>
> On Thu, Jul 29, 2010 at 15:17, Tim <thus...@gmail.com> wrote:
> > It looks like the 'returning' method, which is used on line 75 of
> > adapters.rb, has been removed in Rails 3.0.0.rc:
>
> >http://github.com/rails/rails/commit/b0b9bf320409b66c6c6b680371aca590...
回覆所有人
回覆作者
轉寄
0 則新訊息