How cann I use confirmation token in cucumber? I need this to test a registration without to check an e-mail.
My code:
#b.text_field(:name => 'profile[prename]').set 'Kurt'
#b.text_field(:name => 'profile[surname]').set 'Russell'
#b.text_field(:id => 'profile_email').set 'user#trash-mail.com'
#b.text_field(:id => 'profile_password').set 'password'
#b.text_field(:name => 'profile[password_confirmation]').set 'password'
#b.button(:id => 'profile_submit').click
#ctoken = Profile.last.confirmation_token
#b.goto("http://localhost:3000/profiles/confirmation?confirmation_token=#{#ctoken}")
or:
#b.goto("http://localhost:3000/profiles/confirmation?confirmation_token=#{Profile.last.confirmation_token}")
I become: undefined method `confirmation_token' for nil:NilClass (NoMethodError)
Looks to me that Profile.last returns nil in your case, hence the error message undefined method confirmation_token for nil:NilClass (NoMethodError). Please share code where you define Profile.
Related
Total lack of documentation makes this difficult..
Essentially, I have
package MyApp::Schema;
sub new_schema {
__PACKAGE__->connect(...)
}
Then I have
package MyCatApp::Model::MyApp;
use Moose;
extends 'Catalyst::Model::DBIC::Schema';
## what here;
_PACKAGE__->make_immutable;
How do I make this work? If I have this in my config...
<Model::MyApp>
schema_class MyApp::Schema
traits Caching
user_defined_schema_accessor foo
</Model::MyApp>
I get the following error:
BEGIN failed--compilation aborted at MyCatapp.psgi line 4, line 1.
Error while loading MyCatapp.psgi: Couldn't instantiate component "Either ->config->{connect_info} must be defined for MyCatApp::Model::MyApp or MyApp::Schema must have connect info defined on it.
But adding sub connect_info {} in MyApp::Schema does not change anything. That error is generated on line 480 of this file.
That method seems to be looking at $schema_class->storage->connect_info which I believe is an method on an instantiated object, and not a function in the package. However, if I try to set
__PACKAGE__->config('schema_class', MyApp::Schema->new_schema)
I then get...
Error while loading : Couldn't instantiate component "MyCatApp::Model::MyApp", "Attribute (schema_class) does not pass the type constraint because: Validation failed for 'Catalyst::Model::DBIC::Schema::Types::SchemaClass' with value MyApp::Schema=HASH(0xb4a5ff0) at /usr/local/lib/perl/5.18.2/Moose/Exception.pm line 37
So, how do I go about doing this...
So.. I'm not sure this is right so I won't mark it as accepted but I was pretty damn close.. This line is dead on..
__PACKAGE__->config('schema_class', MyApp::Schema->new_schema)
And the code is in place for that to work, as per the link above on line 480 of Catalyst::Model::DBIC::Schema. However, the type is wrong..
The type of schema_class is SchemaClass. And, SchemaClass is defined here
subtype SchemaClass,
as LoadableClass,
where { $_->isa('DBIx::Class::Schema') };
Now, SchemaClass is a subtype of a MooseX::Types::LoadableClass which essentially just takes a package name and requires it..
The problem is LoadableClass doesn't take an instance of DBIC::Schema. Anyway.. I was just changed it too..
has schema_class => (
is => 'ro',
isa => 'Object',
required => 1
);
Now I can stuff an instantiated schema into schema_class and pass the conditional if($schema_class->storage && $schema_class->storage->connect_info).
I filed a bug on this here
You could instantiate the connection info in your MyApp::Schema by in it doing:
__PACKAGE__->connection(#your_connection_details);
This will set up a Storage on the class itself, not a schema object. This will then pass the Catalyst::Model::DBIC::Schema check and work successfully. I think this achieves what you're after without changing the underlying classes (though might depend on the details not included).
From the documentation you referenced, your MyCatApp::Model::MyApp would look like this:
__PACKAGE__->config(
schema_class => 'MyApp::Schema',
connect_info => {
dsn => 'dbi:Pg:dbname=mypgdb',
user => 'postgres',
password => '',
pg_enable_utf8 => 1,
on_connect_do => [
'some SQL statement',
'another SQL statement',
],
}
);
And in your controller, you would:
my $db = $c->model('MyApp');
With my laravel project I'm trying to send an email with the following code:
$mailTo = "theemail#hotmail.com";
$mailToName = "hisname";
Mail::send('emails.message.showmessage', array( 'name' => $mailToName), function($message)
{
$message->to($mailTo, $mailToName)->subject('New message');
});
But I get the error:
Undefined variable: mailTo
How is this possible? I clearly set the variable with Undefined variable: mailTo, is it being unset in the Mail function?
To use a local variable inside a closure (aka anonymous function) you need to use use()
Mail::send('emails.message.showmessage', array( 'name' => $mailToName), function($message) use ($mailTo, $mailToName)
{
$message->to($mailTo, $mailToName)->subject('New message');
});
All variables specified in use will be available inside the closure all other won't.
Environment:
Apache 2.4
Windows 8
PHP 5.4.14
Zend 1.12
I am doing a very very very simple action on my form, adding an error message on one of my elements with:
$form->getElement('elemetnid')->addError('error');
It works wonders for everyone else, but on my case it also gives out a warning that reads:
Warning: Invalid argument supplied for foreach() in ...\library\Zend\Form\Element.php on line 2247
This only happens when I try to set the error on my MultiSelect element, but if I do so on another element like Text, then everything is great and no warning is given. So I went to inspect the line on the warning, and realized that the problem is that "getValue()" for that element is returning "NULL" and that is not a correct value for the foreach loop inside the framework´s code. But how is that my responsability?
My question is, if anyone knows how to add an error message for a multiSelect without this warning popping up.
Thanks
I can't recreate your error with: Apache 2.2.16, Php 5.3.7 and Zf 1.12.5.
The behaviour is rather odd though. If I invalidate an element before validating the form (by adding an error to an element), it looks like it short circuits the form validation and the error message does not get applied to the form output.
If I try and force in an invalid value via the URL, a value not in my multi-select, I get repeat error messages, and my previously set error messages override the 'X' was not found in the haystack message.
$form = new Zend_Form;
$form->setMethod('GET');
$listOptions = array('one','two', 'three');
$select = new Zend_Form_Element_Multiselect('options', array(
'multiOptions' => $listOptions,
'validators' => array(
array('InArray',
false,
array(array_keys($listOptions)))
)
));
$submit = new Zend_Form_Element_Submit('submit', array(
'label' => 'Do something'
));
$form->addElements(array($select, $submit));
if(isset($_GET) && count($_GET)) {
if(true)
$select
->addError('The form will never validate.')
->addError('Two wrongs don\'t make a right.');
$form->isValid($_GET);
}
$form->setView(new Zend_View);
echo $form;
if ($form->isErrors()) {
echo 'Form did not validate';
var_dump($form->getErrors());
}
Since the API have changed all the times i try to pay with a developper test business i get an error like this :
array (
'TIMESTAMP' => '2013-04-04T21:30:54Z',
'CORRELATIONID' => 'c1929df7ab60a',
'ACK' => 'Failure',
'VERSION' => '97',
'BUILD' => '5618210',
'L_ERRORCODE0' => '10002',
'L_SHORTMESSAGE0' => 'Security error',
'L_LONGMESSAGE0' => 'Security header is not valid',
'L_SEVERITYCODE0' => 'Error',
)
This is the call i make :
https://api-3t.sandbox.paypal.com/nvp?VERSION=97
METHOD=SetExpressCheckout&
CANCELURL=http://url.com&
RETURNURL=http://url.com&
PAYMENTREQUEST_0_AMT=78&
PAYMENTREQUEST_0_CURRENCYCODE=EUR&
PAYMENTREQUEST_0_PAYMENTACTION=SALE&
PAYMENTREQUEST_0_CUSTOM=2856
But all the data in the API call is rightly filled.
I can't add a business account to my developper account.
Just befoire the API changes everything was fine, maybe i'm missing something ? Thank you
I was getting the same problem. I change the parameter name PAYMENTREQUEST_0_AMT to AMT and PAYMENTREQUEST_0_PAYMENTACTION to PAYMENTACTION and that works well. Hope so it works for you as well.
Double check your credentials you are passing over, try copying them again and make sure there is not extra white space before or after your credentials.
Are you missing "&" after https://api-3t.sandbox.paypal.com/nvp?VERSION=97 <--- missing "&"
So you must change to : https://api-3t.sandbox.paypal.com/nvp?VERSION=97&METHOD=SetExpressCheckout&...
Hope this help, thank.
$tip->setGame($em->getRepository('XXXBundle:Game')->find($id));
$form = $this->createFormBuilder($tip)->add('player', 'entity', array(
'class' => 'XXXBundle::FootballPlayer',
/*'query_builder' => function(\XXX\XXXBundle\Entity\FootballPlayerRepository $er)
{
$er->findByCurteam($team->getName());
},*/
))->getForm();
(not really using 'XXX' in my code)
error:
Warning: class_parents(): Class XXX\XXXBundle\Entity\ does not exist
and could not be loaded in
D:\www\xxx\xxx\vendor\doctrine\lib\Doctrine\ORM\Mapping\ClassMetadataFactory.php
line 223
seems the Entity class is not found - strange
Something is strange in your code: 'class' => 'XXXBundle::FootballPlayer', are you sure :: exist? Never seen it, seems like a mistake (maybe can provoke the error).
After testing, yes, it's because of the double :: replace by :: 'class' => 'XXXBundle:FootballPlayer',.