Why does this hash syntax not work in Rails? - hash

session[:user => user, :user_id => [user.id, user.salt]]
For some reason, that never worked for me.
Thoughts on how I can achieve the following code in one line:
session[:user] = user
session[:user_id] = [user.id, user.salt]

Try
session.merge({:user => user, :user_id => [user.id, user.salt]})

I stuck with the original syntax, because I couldn't find an alternative.

Related

SetExpressCheckout first call failed

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.

NoMethodError undefined method mail for

After setting up mailer (3.2.6) in Ruby on rails (3.2.6) I get this error:
NoMethodError (undefined method `mail' for #):
my user_mailer.rb looks like this:
class UserMailer < ActionMailer::Base
default :from => "test#test.com"
def activation_mail(user)
#user = user
mail(:to => user.mail, :subject => "Registration")
end
end
I followed example provided here: http://guides.rubyonrails.org/action_mailer_basics.html
In configuration file I added this line:
config.action_mailer.delivery_method = :test
I also tried with :smtp and configuration for gmail.
What have I missed?
I had a similar problem recently and rectified it by replacing:
def self.activation_mail()
with
def activation_mail()
you should try replacing
def activation_mail(user)
#user = user
mail(:to => user.mail, :subject => "Registration")
end
with
def activation_mail(user)
#user = user
mail(:to => #user.mail, :subject => "Registration")
end
It's a typo error. Your user.mail doesn't exist. Maybe it should be user.email or something else.
I bet your "user" object you're passing is either 1) not instantiated correctly, or 2) an array instead of an individual User object
I found that a typo in your mailer view can cause this problem. The error message is misleading.

SoundCloud API: Tweeting on upload and disable comments

The following PHP code uploads a new track to SoundCloud successfully, but the tweet is not sent.
Is there something I need to have in there as well in order to do this?
$track = $soundcloud->post('tracks',
array(
'track[asset_data]' => '#audio.mp3',
'track[title]' => "my audio",
'track[description]' => "Updated: " . date('l jS F Y h:i:s A'),
'track[sharing]' => 'public',
'track[shared_to][connections][][id]' => '123',
'track[sharing_note]' => 'Have a listen to'
));
Also I'd like to be able to disable comments on the audio I upload, but I wasn't sure what the parameter for that would be too?
Thanks!
dB
I'm unable the repro the sharing problem. Please note that sometimes sharing on other social networks doesn't happen right away. Are you still having trouble? Here's the code I used:
<?php
require_once 'Services/Soundcloud.php';
$client = new Services_Soundcloud("foo", "bar");
$client->setAccessToken('ACCESS_TOKEN');
$track = $client->post('tracks', array(
'track[title]' => 'Foooo',
'track[asset_data]' => '#/Users/paul/audio.wav',
'track[sharing]' => 'public',
'track[shared_to][connections][][id]' => 'CONNECTION_ID',
'track[sharing_note]' => 'Check it out'
));
print_r($track);
Also verify that your CONNECTION_ID is correct. Some code to get a list of connections so you can verify the id:
<?php
require_once 'Services/Soundcloud.php';
$client = new Services_Soundcloud("foo", "bar");
$client->setAccessToken('ACCESS_TOKEN');
print_r(json_decode($client->get('me/connections')));
Unfortunately there's no way currently to disable comments via the API. I'll file a bug and see about getting this fixed.
Hope that helps!

Using HTML::FormFu, how do you change a field value *after* processing so that it appears modified in Template Toolkit?

For example, if I process a form:
my $form_input = { input_data => '123' };
$form->process($form_input);
Then I want to alter the value of 'input_data':
my $clearme = $form->get_field('input_data');
$clearme->value("546"); # doesn't seem to work
..Before pushing the form object to TT:
template 'index' => { form => $form }; # using Dancer
'input_data' seems to retain it's original value (123). Any hints on what I'm doing wrong, or what I should be doing?
Thanks
After looking at the documentation and doing some testing, I think you want
$form->add_valid(input_data => '546');

email component smtp error cakephp

im getting this error when sending emails with cake's email component
[smtpError] => 535 5.7.1 http://mail.google.com/support/bin/answer.py?answer=14257 r11sm77490vbx.11
any ideas? here's my code...
$this->Email->to = array(' juan <name#gmail.com>');
$this->Email->from = 'name#gmail.com';
$this->Email->subject = 'Welcome to our really cool thing';
$this->Email->template = 'simple_message';
$this->Email->sendAs = 'both';
$this->Email->smtpOptions = array(
'port'=>'465',
'timeout'=>'30',
'auth' => true,
'host' => 'ssl://smtp.gmail.com',
'username'=>'name#gmail.com',
'password'=>'********',
);
You have a space there before your name, which could possibly be sending the wrong data. Have you tried the code without that extra space?
Well, the link in the error message to google's support forums say that the username and password combination are incorrect. I'd recommend that you try logging in to that gmail account with the specified password, just to triple check that you're not mistaken. That happens a lot to me, all the time.
Secondly, are you sure you're supposed to put the #gmail.com in for the username? Maybe it should just be 'name' rather than 'name#gmail.com'.
Apart from that stated by #Travis ... i would also suggest that the from should also be constructed in this format "Name " ... otherwise I don't think the email will go through.