authlogic perishable token can't be null - ruby-on-rails

I get this erorr eerytime I try to create a user from the console. I used to be able to do this, but ever since I turned off PT maintenance, this could have become a problem.
Thing is I do supply a value for the PT using Authlogic::Random.friendly_token, but it seems this value never shows up in the SQL statement.
What do I need to do ?
ActiveRecord::StatementInvalid: /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:219:in log': Mysql::Error: Column 'perishable_token' cannot be null: INSERT INTOusers(city,zip,created_at,single_access_token,image_file_name,voting_power,crypted_password,image_file_size,image_url,updated_at,perishable_token,username,role_id,image_content_type,lng,posts_count,failed_login_count,current_login_ip,sex,password_salt,current_login_at,persistence_token,login_count,last_login_ip,age,lat,last_login_at,image_updated_at,email,state,active,processing`) VALUES(NULL, '94131', '2010-09-07 16:26:38', '8R0L3UMxlytO2QNrXMQ', NULL, 0, '3590f21c99ecad3fa2ece943d23f55af735e9713d0d325111763b10b3e3f8a455e7ed323b6b3f5d7a721f5afc81beff5da1f2d6b20454c399751eed1623d3b7d', NULL, NULL, '2010-09-07 16:26:38', NULL, 'asitmi', NULL, NULL, NULL, 0, 0, NULL, 1, 'mrqq5O4gFsyMcExLEOsH', NULL, 'b3ff5cd7e942212b1976f8d57941516489a0cbc4360493ff3f9b2e17e4aae48c3f53944674745ef911ca0947f62d2b5d6da10a55f7b9073f1b4c4f0b6f68b540', 0, NULL, 34, NULL, NULL, NULL, 'adfds#fddas.com', NULL, NULL, 1)
acts_as_authentic do |a|
a.validates_length_of_password_field_options = { :within => 1..15, :on =>:update, :if => :has_no_credential?}
a.validates_length_of_login_field_options = { :within => 1..15, :on =>:update, :if => :has_no_credential?}
a.account_merge_enabled true
# set Authlogic_RPX account mapping mode
a.account_mapping_mode :internal
a.disable_perishable_token_maintenance = true
a.login_field = 'username'
end

well it this could have been a problem with mass-assignment.
If I do a
u.perishable_token = Authlogic::Random.friendly_token
u.save
then it works just fine.

Related

How to set applicaion fee to zero for reccurring payments using Stripe::Plan API

I have been asked to set up an application fee of zero as per my Client's request. I was successfully able to do it using Stripe:Charge create by simply not passing the application fee.
However, with recurring payment we use a different API which is Stripe::Plan.create. This does not allow me to set the application fee to zero, so my recurring payments are been charged a certain amount of fee
Shared below is the code for recurring payment:
# on recurring retrieve application fee
def retrieve_invoice_application_fee(invoice_id)
begin
invoice_response = Stripe::Invoice.retrieve(invoice_id, :stripe_account => candidate.stripe_gateway_id, stripe_version: '2019-12-03')
application_fee = 0
rescue StandardError => e
puts "************ Invoice retrieve #{e} ************"
end
application_fee
end
def create_or_find_stripe_plan
begin
response = Stripe::Plan.retrieve("#{candidate.stripe_gateway_id}-#{amount}",{:stripe_account => candidate.stripe_gateway_id, stripe_version: '2019-12-03',})
rescue => e
response = e
end
if response.inspect.to_s.downcase.include?("no such plan")
response = Stripe::Plan.create({
:amount => amount_cents,
:interval => 'month',
:interval_count => 1,
:currency => candidate.candidate_country[candidate.country.to_s.to_sym][:currency],
product: {name: "#{candidate.stripe_gateway_id}-#{amount}", statement_descriptor: "test statement", },
},
:stripe_account => candidate.stripe_gateway_id, stripe_version: '2019-12-03',
)
end
response
end
I suppose the billing_scheme parameter can help me fix this. Shared below are the debugged logs for a test paument
=> #<Stripe::Plan:0x3fb492612ffc id=plan_LxGnco3QDxIUyR> JSON: {
"id": "plan_LxGnco3QDxIUyR",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 5000,
"amount_decimal": "5000",
"billing_scheme": "per_unit",
"created": 1656352923,
"currency": "usd",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {},
"nickname": null,
"product": "prod_LxGnqDEOfY6Z8a",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type"

Dividing up an index params into multiple pages

I have a list of records that I have displayed on an index page. (they are displayed in a table form). Because there are a number of them I am trying to divide them up to about 30 records per page. I've created a search params functionality with the index displayed beneath it.
The problem that I am having is that I am having trouble getting more than one page to render on my list. As of right now I have about 150 records. However I only have one page listed with only 30 records on it and am not able to sort through them. Would anybody have any idea what I could be missing?
Here is the segment in my code where this gets addresssed.
def search_params
default_index_params.merge(params.fetch(:record_collection, {})).with_indifferent_access
end
def default_index_params
{
per: 30,
page: 1,
sort_by: "created_at",
sort_direction: "desc",
customer_id: 0
}
end
In my view, I do have a little bit of coffee-script that plays a role in the table itself. I don't know if it is the root of my problem, but I have it here as well.
:coffeescript
$('#record_table').dataTable
aaSorting: [[1, 'asc']]
bPaginate: false
bFilter: false,
aoColumns:[null, null, null, null, null, { bSortable: false }, null, { bSortable: false }]
My record collection is used for defining the params, i don't think that it is useful for this problem. (but could certainly post if needed)
Thanks in advance to anybody who is able to help figure out what is going on with this.
You need to pass paging: true and pageLength: 30 in coffescript, and just remove page: 1,per: 30 from default_index_params method. So your coffeescript will look like this:
:coffeescript
$('#record_table').dataTable
aaSorting: [[1, 'asc']]
paging: true
pageLength: 30
bFilter: false,
aoColumns:[null, null, null, null, null, { bSortable: false }, null, { bSortable: false }]
your default_index_params will looks like this:
def default_index_params
{
sort_by: "created_at",
sort_direction: "desc",
customer_id: 0
}
end

HybridAuth getUserProfile returns Trying to get property of non-object

Well i'm using HybridAuth for google, FB and Twitter, and for FB works just fine, google returns empty user profile.
AccessToken is OK
getUserProfile() data is set NULL:
object(Hybrid_User)#8 (3) { ["providerId"]=> string(6) "Google" ["timestamp"]=> int(1452502079) ["profile"]=> object(Hybrid_User_Profile)#9 (22) { ["identifier"]=> NULL ["webSiteURL"]=> NULL ["profileURL"]=> NULL ["photoURL"]=> NULL ["displayName"]=> NULL ["description"]=> NULL ["firstName"]=> NULL ["lastName"]=> NULL ["gender"]=> NULL ["language"]=> NULL ["age"]=> NULL ["birthDay"]=> NULL ["birthMonth"]=> NULL ["birthYear"]=> NULL ["email"]=> NULL ["emailVerified"]=> NULL ["phone"]=> NULL ["address"]=> NULL ["country"]=> NULL ["region"]=> NULL ["city"]=> NULL ["zip"]=> NULL } } } }
Any idea what to check?
just pointing for other user that experienced with same behaviour.
you can enable debug mode by adding parameters on config file, just like this
array(
"base_url" => "",
"providers" => array (
"Google" => array (
"enabled" => true,
"keys" => array ( "id" => "", "secret" => "" )
),
"Facebook" => array (
"enabled" => true,
"keys" => array ( "id" => "", "secret" => "" )
),
"Twitter" => array (
"enabled" => true,
"keys" => array ( "key" => "", "secret" => "" ),
"includeEmail" => true
),
),
// if you want to enable logging, set 'debug_mode' to true
"debug_mode" => false,
// then provide a writable file by the web server on "debug_file"
"debug_file" => "log.txt"
);
then you can check log, that's correct to use google user data we need to enable google+ api on google developer console,
and need to wait a while during propagation

Keep unveiled credentials in Elasticsearch (using jdbc-river)

I use the jdbc-river to fill my Elasticsearch instance from a PostgreSQL database. The river's record is created with the following ruby's code (since I query ES from a Rails app):
require 'elasticsearch'
client = Elasticsearch::Client.new
client.create :index => "_river", :type => "ldi", :id => "_meta", :body =>
{
:type => :jdbc,
:jdbc => {
:driver => "org.postgresql.Driver",
:url => "jdbc:postgresql://localhost:5432/" + ENV['DB_NAME'],
:user => ENV['DB_USER'],
:password => ENV['DB_PASS'],
:index => ENV['DB_NAME'],
:type => "ldi",
:sql => "select id as _id, * from ldis"
}
}
I'm using envirnoment variables for the database credentials to avoid showing the actual ones. The problem is that once the record is added to ES, actual credentials are unveiled. Thus, you can query ES and obtain something like this:
"hits": {
"total": 6,
"max_score": 1,
"hits": [
{
"_index": "_river",
"_type": "ldi",
"_id": "_meta",
"_score": 1,
"_source": {
"type": "jdbc",
"jdbc": {
"driver": "org.postgresql.Driver",
"url": "jdbc:postgresql://localhost:5432/any_dbname",
"user": "any_dbuser",
"password": "any_dbpass",
"index": "any_index",
"type": "ldi",
"sql": "select id as _id, * from ldis"
}
}
}
....
Is there any way to keep them in secret?

Google Charts: multiple lines with custom tooltips

I have a Google LineChart with multiple lines. These points do not share the same X value's so i have to format my data in a certain way to make it work:
var data = google.visualization.arrayToDataTable([
["Y", "Your X & Y", "Product 1", "Product 2", "Product 3"],
[419, 589, null, null, null],
[386, null, 504, null, null],
[386, null, 526, null, null],
[387, null, 543, null, null],
[395, null, 564, null, null],
[402, null, 591, null, null],
[408, null, 612, null, null],
[378, null, null, 501, null],
[398, null, null, null, 600],
[460, null, null, null, 500]
]);
Now i want to add custom tooltips to these lines, i've tried adding an extra column and setting the role to tooltip.. but this only affects the first line.
see both charts (with and without tooltip): http://jsfiddle.net/TD92C/8/
How do i add custom tooltips for all lines? Thanks
SOLVED:
http://jsfiddle.net/asgallant/TD92C/14/
you have to make your variable like this
var data = google.visualization.arrayToDataTable([
//Columns
["Y", //Name of the X-axis marker
"Your X & Y",{type: 'string', role: 'tooltip'},
"Product 1",{type: 'string', role: 'tooltip'},
"Product 2",{type: 'string', role: 'tooltip'},
"Product 3",{type: 'string', role: 'tooltip'},],
//Rows
//Add tooltip column after every value in each row
[419,589,"tooltip info about your x & y",null,'',null,'',null,''],
[386,null,'',504,'','Custom Tooltip',null,'',null,''],
[386,null,'',526,'Custom Tooltip',null,'',null,''],
[387,null,'',543,'Custom Tooltip',null,'',null,''],
[378,null,'',null,'',501,'Custom Tooltip',null,''],
[383,null,'',null,'',511,'Custom Tooltip',null,''],
[368,null,'',null,'',null,'',526,'Custom Tooltip'],
[373,null,'',null,'',null,'',547,'Custom Tooltip'],
]);
Fiddle
Data is looking different but if you correct the first element to a string which is exactly as the columns displayed in 1st column index it will be correct

Resources