Comments (13)
Can you try to use around_action { |_, &block| Chewy.atomic(&block) }
? Would it help?
from chewy.
No, still getting the same error
from chewy.
Try around_action { |block| Chewy.atomic(&block) }
Try
around_action :chewy_atomic
def chewy_atomic &block
Chewy.atomic(&block)
end
It seems the behavior of around_filter was changed somehow in rails 4.1
from chewy.
around_action { |block| Chewy.atomic(&block) }
givers error
wrong argument type HomeController (expected Proc)
and
around_action :chewy_atomic
def chewy_atomic &block
Chewy.atomic(&block)
end
givers error
wrong number of arguments (2 for 0..1)
from chewy.
Ok, lets research:
around_action :chewy_atomic
def chewy_atomic *args, &block
p args
p block
end
from chewy.
args ==> []
block ==> #Proc:0xb20456e8@/home/rtcoms/.rvm/gems/ruby-2.1.0@rails41_upgrade/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:298
from chewy.
Ok, I'll try to debug it later
from chewy.
Let me add two cents: The public contract for around filters is that they have to yield
:
around_action :chewy_atomic
def chewy_atomic
Chewy.atomic do
yield
end
end
That's the way the around action is supposed to be written. Also, in instance methods self
is of course the controller in case you need to do anything with it.
from chewy.
Xavier, but what have been changed since rails 3 in filters? Why the first approach is not working in 4?
from chewy.
Not sure, there seems to be something going on with around filters being called with blocks but I don't see anything related to that. Let me investigate a bit.
from chewy.
I ran a bisect and this seems to be a regression in Ruby on Rails introduced by rails/rails@07da960.
@tenderlove does it ring a bell to you?
Test case for Action Pack:
require 'abstract_unit'
module AbstractController
module Testing
class CallbackController < AbstractController::Base
include AbstractController::Callbacks
around_filter { |controller, &block|
controller.instance_eval do
@aroundz = 'FIRST'
end
block.call
controller.instance_eval do
@aroundz << 'SECOND'
end
}
def index
@text = 'foo'
self.response_body = @text
end
end
class TestCallbacks2 < ActiveSupport::TestCase
def setup
@controller = CallbackController.new
end
test 'around_action with block' do
@controller.process(:index)
assert_equal 'FIRSTSECOND', @controller.instance_variable_get('@aroundz')
assert_equal 'foo', @controller.instance_variable_get('@text')
end
end
end
end
from chewy.
Yeah, now I remember, I've faced this previously here: pyromaniac/active_data@6a5def3#diff-187370617b60bc61e60e7ced18a88b66L46 and found a kind of workaround.
from chewy.
Well , code give b y @fxn worked. I was getting error because of something else
around_action :chewy_atomic
def chewy_atomic &block
Chewy.atomic(&block)
end
from chewy.
Related Issues (20)
- Support PITs (points in time) and search_after HOT 4
- is there a way to set `Chewy.strategy(:lazy_sidekiq)` globally? to make all updates asynchronously HOT 2
- Readme comment on Ruby 3 + Rails 6.1
- `Elasticsearch::Transport::Transport::Errors::Found`
- Cleanup journal throws `Yajl::EncodeError: Max nesting depth of 256 exceeded`
- Old indices are not being cleared up after a reset
- Port PR #874 to the 7.0.x branch
- Trying to use Pagy pagination with Chewy, running into autoloading will_paginate gem
- Breaking change at 7.2.4
- I have a question regarding elasticsearch-ruby gem
- Support rails parallel testing
- Warning when upgrading to Rails 7.1
- "#<Chewy::UndefinedUpdateStrategy: Index update strategy is undefined for current context.\n Please wrap your code with `Chewy.strategy(:strategy_name) block.`\n>"} HOT 3
- Update Index Derived from Multiple Associated Models
- Index#order - add missing first/last option
- Deprecated the `zrangebyscore` command
- How to migrate to chewy 7.2 HOT 1
- can not use import to delete missings source objects
- Rake chewy:sync should work for complex "outdated_sync_field" values HOT 2
- Use ENV variable to name index by default HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chewy.