Reputation: 5962
I am running a Rails app that after upgrading the Ruby version to 2.5.1 and also 2.6.0 stopped working. I noticed that it has something to do with passing a block in controller's callbacks:
prepend_before_filter only: [:create, :destroy] { request.env["devise.skip_timeout"] = true }
fails with an error:
syntax error, unexpected '{', expecting keyword_end
...ter only: [:create, :destroy] { request.env["devise.skip_tim
My setup is:
devise (4.6.1)
rails 5.0.7
ruby 2.5.1
pundit 2.0.1
I upgraded Ruby version I was using to 2.6.0 and had a problem, then went down to 2.5.1 and the problem still persisted
I also found these twho threads that seem to talk about a similar problem: https://github.com/plataformatec/devise/issues/4703 Rails 4 before_action, pass parameters to invoked method
I updated Devis and Pundit, but without any luck :\
Upvotes: 2
Views: 554
Reputation: 680
For me works adding parentheses ():
prepend_before_filter(only: [:create, :destroy]) { request.env["devise.skip_timeout"] = true }
Upvotes: 1
Reputation: 107107
I would suggest replacing prepend_before_filter
which was deprecated with prepend_before_action
and using parentheses
prepend_before_action(only: [:create, :destroy]) { request.env["devise.skip_timeout"] = true }
or using the do ... end
block syntax
prepend_before_action only: [:create, :destroy] do
request.env["devise.skip_timeout"] = true
end
Upvotes: 4