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

55 views
Skip to first unread message

Tim

unread,
Jul 29, 2010, 3:17:30 PM7/29/10
to 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

unread,
Jul 29, 2010, 3:21:04 PM7/29/10
to 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

unread,
Jul 29, 2010, 3:44:13 PM7/29/10
to 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...
Reply all
Reply to author
Forward
0 new messages