Rails 3: Error with Authlogic in console - ruby-on-rails-3

I'm trying create some users in the console. I'm getting the following error:
Authlogic::Session::Activation::NotActivatedError: You must activate the Authlogic::Session::Base.controller with a controller object before creating object
This error occurs in an after_create which only job is to send an email to the user. If I disable this after_create, everything works, but this means no email is sent.
I tried to apply a solution found here, but it didn't work:
http://www.tatvartha.com/2009/09/working-with-authlogic-in-scriptconsole/
What's going on?
Thank you

Related

RSpec - Expecting a 500 error after completing a JS prompt modal

I'm working on an interface where the user creates an entity and gives it a name via a simple JS alert prompt, and by design our back-end returns a 422 error if you submit a name that already exists in the database. My task is to then display a message on the front-end after this error happens.
I'm using accept_prompt(with: "NAME") to properly test the modal functionality, but I'm having a hard time telling Rspec to expect an error from the attempted POST that results from completing the prompt.
I've tried the code below and variations of it but it always seems like Rspec fails with "no error was raised" and then immediately fails with ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR(the exact error I'm trying to expect).
expect do
accept_prompt(with: "NAME") do
find(".selector .selector-item:first-child").click
end
end.to raise_exception
I've even tried the below code to no avail:
expect accept_prompt(with: "NAME") do
find(".selector .selector-item:first-child").click
end.to raise_exception
Is there some other known way to expect an error from a modal interaction in Rspec, or is it simply not possible?
We just resolved the issue, turns out the 500 error in the spec was caused by a problem with my spec configuration, unrelated to the 422 error that we expected to get and handle in the interface. Once we addressed that issue the 500 error went away and did not break the test, allowing us to continue running assertions against the frontend error validation.
So while there doesn't seem to be a way to actually catch and expect a backend error using Capybara, we didn't need to because that error wasn't supposed to be happening.

Finding the source of an error on sidekiq

I am running a job in the background with sidekiq and using perform_later with rails 5.1.7.
Right now in the sidekiq dashboard I am getting an error related to a method, but I am calling that method more than once, so I don't know where exactly is the problem coming from.
If I use perform_now it works, but not with perform_later
In the "retry" section of the dashboard I am getting for this job the following error:
NameError: undefined local variable or method `payload' for #<AppServices::BookingService

Circuit SDK error on method circuit.logon

I'm trying to move my bot for Circuit to production. My app for it uploaded on Azure Web App Service. When I test bot on sandbox it works great. But if I change only config (client_id, client_secred and domain) and restart app it falls on method circuit.logon with this error message:
Error on ciruit.logon. The Application null is not enabled for scope ::=[CALL_RECORDING]
If I specify a scope on creating circuit client like that:
scope: 'READ_USER_PROFILE'
or any other scope it changes to:
Error on ciruit.logon. The Application null is not enabled for scope ::=[READ_USER_PROFILE]
The Application null bothers me. And I tried all scopes due to last part of error but it won't work. What could cause this error?
As Roger said :
This should work fine, especially since the same code worked on the
sandbox. If you don't specify a scope in the Circuit.Client
constructor, then the SDK asked for all scopes. In that case the app
should be registered with all scopes. But if you just request
READ_USER_PROFILE for example in the Circuit.Client constructor, then
the app only need at least that scope set in its registration. The
'application null' is not a problem. The only thing I can think of is
that the bot registration does not have any scopes defined. Try to
change the registration scopes for your bot and save if again
I copy his comment as "an answer" so that the Andrey has the opportunity to select a "good answer" for his request.

$model->validate() method is printing 'test'

I am doing a website on YII and PostgreSQL. It is recurrently exiting inside $model->validate() method by printing 'test'. I have searched whole code, There is no exit code on controller , model, beforeValidate(), afterValidate(), even whole project.
Question
How can i debug on such scenario. I have only access to ftp, Netbean as IDE, but no localhost. How to find which file is printing exit code or do you have any idea ?
Thank you,
Ram
Messages can be logged by calling either Yii::log or Yii::trace. The difference between these two methods is that the latter logs a message only when the application is in debug mode.
Yii::log($message, $level, $category);
Yii::trace($message, $category);
When logging a message, we need to specify its category and level. Category is a string in the format of xxx.yyy.zzz which resembles to the path alias. For example, if a message is logged in CController, we may use the category system.web.CController. Message level should be one of the following values:
For more details, refer this YII Tutorial

Rails 3.2 Serialize & Deserialize Mail

I'm trying to save email to a database, to send it later via a rake task. It was pretty easy in rails 2.3.8 (TMail), but I'm having trouble with rails 3.2.
Once I get the Mail object (mail), I call mail.encoded to serialize the email. I save this to the database.
My rake task loads the encoded message, but I can't find a way to recreate the mail object and call deliver (deserialize).
Mail.new(mail.encoded) seems like it should work, but the delivery fails because Mail.new doesn't get the default ActionMailer SMTP settings.
Anyone else doing something like this?
Thanks!
Alright, got this working.
To serialize the email I do the following.
email = mail(:to => 'to#me.com', ....)
string = mail.encoded
# later one
mail.new(email.string)
Mail.deliver(mail)
This appears to skip any HTML validation.
I can't set the Mail send settings (SMTP, etc), but I think it defaults to :sendmail, and that's working on the web server.