Ruby

I just realized that the facebook authentication is failing, this is the error I get in heroku: [shell] 2017-04-20T16:23:30.596766+00:00 app[web.1]: I, [2017-04-20T16:23:30.596716 #7] INFO -- omniauth: (facebook) Callback phase initiated. 2017-04-20T16:23:30.647209+00:00 app[web.1]: E, [2017-04-20T16:23:30.647151 #7] ERROR -- omniauth: (facebook) Authentication failure! invalid_credentials: OAuth2::Error, : [/shell] and the way to...

Hey guys how's it going?

Why Netsuite does not publish the available operators for searching and makes our lives easier? well I don't know but today I'm going to share with you how to search custom records by a custom field within Netsuite in my case for instance: I want to search all the Sales order that have an empty custom field you know a custom field is not a default field within the Netsuite Schema and my custom field is called: 'custbody_order_number', so based in that this is the code I have created: Btw I'm using for that this gem: https://github.com/NetSweet/netsuite

Searching all type of sale orders records that do not have a empty custom field

[ruby] def search_empty_sales_order_number [ { field: 'customFieldList', value: [{ field: 'custbody_order_number', type: 'SearchStringCustomField', operator: 'empty' }] } ] end search_result = NetSuite::Records::SalesOrder.search( criteria: { basic: search_empty_sales_order_number } ) search_result.results [/ruby]

searching only "salesOrder" types  that do not have a empty custom field

[ruby] def search_empty_sales_order_number [ { field: 'customFieldList', value: [{ field: 'custbody_order_number', type: 'SearchStringCustomField', operator: 'empty' }] }, { field: 'type', operator: 'anyOf', type: 'SearchEnumMultiSelectField', value: ['_salesOrder'] } ] end search_result = NetSuite::Records::SalesOrder.search( criteria: { basic: search_empty_sales_order_number } ) [/ruby] Searching by multiple custom fields [ruby] def search_empty_tracking_link_fullfilments [ { field: 'customFieldList', value: [{ field: 'custom_tracking_number', type: 'SearchStringCustomField', operator: 'notEmpty' }, { field: 'custom_transaction_id', type: 'SearchStringCustomField', operator: 'empty' } ] }, { field: 'type', operator: 'anyOf', type: 'SearchEnumMultiSelectField', value: ['_itemFulfillment'] } ] end search_result = NetSuite::Records::ItemFulfillment.search( criteria: { basic: search_empty_tracking_link_fullfilments } ) search_result.results [/ruby]

[ruby] validates_format_of :url, :with => /\A(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w\.-]*)*\/?\Z/i [/ruby] Notice that I'm using "A" and "Z" because if you use ^ and $ you will see this warning security from Rails validators. [ruby] Valid ones: 'www.crowdint.com' 'crowdint.com' 'http://crowdint.com' 'http://www.crowdint.com' Invalid ones: 'http://www.crowdint. com' 'http://fake' 'http:fake' [/ruby] ...

How to create a new nested attribute form for only new records in a has_many relationship using simple_form, well according to this stackoverflow http://stackoverflow.com/questions/14884704/how-to-get-rails-build-and-fields-for-to-create-only-a-new-record-and-not-includ I was trying to create a new records using nested attributes the problem with that solution it is that if the...

I just found great the way that the cancel subscription works(ruby pattern) in the braintree gem, that's why I'm sharing this pattern with you guys: Gem https://github.com/braintree/braintree_ruby [ruby] # Just execute this class method Braintree::Subscription.cancel(subscription2.id) [/ruby] Logic Behind the scenes [ruby] # lib/braintree/subscription.rb module Braintree class Subscription def self.cancel(subscription_id) ...