ToddT

0

votes
0

answer
5

views

Include / require common lib file in rake task

I tried these things suggested in this post and nothing worked I give up, I've tried everything and back again and for the life of me I can't include / require my common methods file in my rake task. First I thought that if you added a file in the lib folder and made sure it was in the load path tha...
ToddT
1

votes
1

answer
107

views

SystemStackError (stack level too deep) in Model

Unsure of why this is happening?? Still a noob.. I am just updating one field in the Mine table before I save the record. All of the variables are being pulled in accurately.. The below line returns what its supposed too. CreateFulfillmentService::NON_US_MARKETPLACES.include?(self.marketplace) And...
ToddT
1

votes
1

answer
1.3k

views

Hash rocket vs colon in render json:

I am rendering a response to a POST request from a webhook. I just realized that when I render json: thingee and I log thingee it has hash rockets which are not valid json. I've seen where people puts the hash and it looks fine, but that's not what I'm doing, I'm rendering a hash as JSON in response...
ToddT
1

votes
1

answer
282

views

Vue - Is there a way to scope $refs on a form

I am passing in props to my form. So the data in the form can be populated from these props or from user entry. Because I'm using props I don't have data defined for these elements. But instead am using v-model and passing in my props. The problem then is when I want to submit, how can I get all the...
ToddT
1

votes
2

answer
49

views

Ruby array inserting mystery characters

this is bizarre.. I'm requesting data from the Amazon Product Advertising API with the Vacuum gem.. and using an array to pass the id it needs.. and for some reason between when I send it, and when the API gets it there is a back slash inserted in the id?? AND its consistently doing it.. lookup_ite...
ToddT
1

votes
1

answer
238

views

ebay BulkDataExchangeRequests API XML - UUID is missing

I'm testing a request to the LMS side of the eBay API by sending a AddFixedPriceItemRequest to BulkDataExchangeRequests via createUploadJob. When I do this I get the error: 'UUID is required' even though in the documentation that I can find it says UUID is optional. However, I am including a UUID...
ToddT
1

votes
2

answer
1.2k

views

Redis save a hash and get a hash

Can't get this to work.. I just want to save a hash to redis and then retrieve the entire hash from Redis.. not an array of values or keys, I just want the hash.. As an example: jack = Redis.new jack.hset('cart:1', 'token', '456789') pp jack.hget('cart:1', 'token').class # returns an array Is it pos...
ToddT
2

votes
1

answer
243

views

Bootstrap modal not closing and refreshing index page

My edit/update modal isn't working correctly. I want it to update the db, close the modal and return the user back to my index page where the table containing my products should be updated. Right now its just updating the db, but not closing the modal and the user has to refresh the browser to see t...
ToddT
1

votes
2

answer
2.5k

views

Create hash from variables in loop

I want to end up with an array of hashes. I am starting with an array of codes: @codes = ['123', '456', '789'] I take each of those codes and hit an API with them and it returns values that I parse into variables in a loop, like so: @codes.each do |x| @y = x.get_some_data @brand = @y[brand] @size =...
ToddT
2

votes
2

answer
1.1k

views

Make db column optional or not required so I can create record

I have a column on a table that may or may not get populated when a new record is created. Let's call it free_shipping_amount and its type integer, and it resides in the shipping_methods table. I also have a form that is backed by this ShippingMethods model. So I don't want this field to display as...
ToddT
2

votes
1

answer
2.5k

views

Datatables child row not showing

I am following this blog post on Datatables Sliding Child Rows but I can't get my rows to show when clicked.. I just want to be able to show the child row when the first column is clicked. What am I doing wrong? My jQuery $(document).ready(function(){ $('#products').DataTable({ 'lengthMenu': [[20, 5...
ToddT
4

votes
2

answer
3.3k

views

Pry like debugger for Sidekiq?

I've tried pry and remote-pry, but no luck. I'm familiar with logging, but I want to be able to step thru my code and look at variables. Does anyone know of anything I can use to debug Sidekiq?
ToddT
2

votes
1

answer
779

views

Calling helper method in services

Can't seem to call this helper method from a service I created. They look like this: # app/controllers/application_controller.rb class ApplicationController < ActionController::Base helper_method :activate_session_with_id def activate_session_with_id(domain, token) #do some stuff end end My service...
ToddT
3

votes
1

answer
460

views

record not saving when before_save action is called

Can't figure this out.. Not sure why the record isn't being saved.. the method is being called properly, and all the fields are present, and the logic is correct.. Here is my model code: class Mine < ActiveRecord::Base belongs_to :shop validates :merchant_id, presence: true validates :auth_token, pr...
ToddT
1

votes
1

answer
61

views

Where to put scratch file to be able to access Model data/methods

I have a file that I use for testing ideas and ensuring a code refactor is working. I'd like to be able to access my Shop Model data from within this scratch file. For instance I'd like to be able to do this in the tester.rb file: pp Shop.all Where would I put it, and what should it inherit from in...
ToddT
2

votes
3

answer
242

views

Inherit controller class from gem

I am using the ShopifyApp gem, which has an action called receive in its WebhooksController. As seen here: Webhooks controller In my WebhooksController controller I am trying to override that receive action by doing the following: class WebhooksController < ShopifyApp::WebhooksController def receive...
ToddT
1

votes
7

answer
86

views

javascript - How to check for existence of object in array

How can I check for the existence of an object in an array in javascript? Here is a simple example. Let's say I have an array that looks like this: let array = [{'zone': 'WV', 'zip': '56855'}, {'zone': 'SC', 'zip': '28031'}, {'zone': 'TN', 'zip': '84755'}] And now I want to add an object to my arr...
ToddT
1

votes
1

answer
26

views

Keep Unpermitted parameters from printing to log

Is there a way to stop unpermitted params from printing to my logs? Its just a huge mess and making it hard to look thru the unpermitted params in order to find issues. Any suggestions?
ToddT
2

votes
1

answer
1.7k

views

Using attr_encrypted to encrypt and store API token, but how to de-crypt in order to use

Building an app that pulls data from merchant's accounts on demand. I've setup my model, installed the attr_encrypted gem, and everything is being stored properly as encrypted. I've created a method that takes the token and sends it to the API, but I need to send the de-crypted version. The token is...
ToddT
1

votes
2

answer
31

views

Hash not being added to array

I give up, I have no idea why the hashes I'm creating are not being added to the end of the array. When I pp the hash it is correct, but for some reason the first hash is getting duplicated, while the second hash isn't being added.. The result I'm getting is this: [{:id=>'36757153479', :quantity=>1...
ToddT
1

votes
2

answer
1.4k

views

Update Shopify cart with ajax without page refresh

I am changing a users Shopify shopping cart with Ajax, the cart is being changed successfully but in order to display the updated cart the user has to refresh the page. I want to display the cart changes WITHOUT a refresh. I'm using the ajax api just fine, and I can add and remove items with: Shopif...
ToddT
2

votes
1

answer
512

views

Vuejs function in mounted lifecycle hook

I would like my hideMe() function to be called during the mounted lifecycle hook in my Vuejs code. Currently it is not, and I don't understand why. My code is below: export default { data() { return { show: 'initial' } }, methods: { hideMe() { if(this.$vuetify.breakpoint.name == 'xs') { console.log...
ToddT
1

votes
1

answer
177

views

Use max_by in Ruby to find the key for the maximum number in a hash

I need to find the category, within an array, that holds the 'largest' weight. I define the weights in an environment variable: CATEGORY_WEIGHTS = { 'small_standard': 0, 'large_standard': 1, 'small_oversize': 2, 'medium_oversize': 3, 'large_oversize': 4 } In this example, the 'largest' weighted cate...
ToddT
3

votes
3

answer
238

views

Find partial match of hash against array of hashes

I have an array of hashes that I am matching against. me = [{paid: true, setup: true, send_to: 'somewhere'}, {paid: true, setup: false, send_to: 'somewhere else'}, {paid: false, setup: true, send_to: 'somewhere new'}, {paid: false, setup: false, send_to: 'somewhere outside'}] And I have a hash with...
ToddT
2

votes
1

answer
30

views

'é' character with Ruby i18ln translations

I'm using i18ln in Ruby and providing translations for my views. My spanish translations require an acute e, or this é . This is my simplified translation in my es.yml file es: headline: 'Hola, tus créditos son:' I am trying to make the é appear correctly, and as this is not HTML, I can't use...
ToddT
3

votes
3

answer
90

views

Vuetify - How to access data in form rule

Can I access a data element in a rule? Here is my code running I'm trying to flip the value of a data element on a text field rule in a Vuetify form. The rule itself works fine, however I'm unable to access the data element, I'm getting this error: TypeError: Cannot set property 'disabled' of undefi...
ToddT
2

votes
1

answer
52

views

Search elements of array and return element but keep original class

I have an array my_array that is made up of multiple MyClass objects. I need to search this array and return an object from the array, but keep the object's class as the original MyClass: # my_array[0] is a MyClass object # my_array is an Array select works perfectly, but it returns the element as a...
ToddT
2

votes
0

answer
99

views

Shopify Webhook not sending to controller

Thru the Shopify API I can create webhooks great. I've created ones that point to RequestBin just fine, the data that is sent to RequestBin is perfect. But when I turn it towards my own controllers nothing happens. I have a binding.pry in my controller to catch anything that comes in, and nothing ev...
ToddT
2

votes
1

answer
677

views

Rails Gem - Peddler for Amazon API

Looking for some examples to figure out this gem.. Here is the link: https://github.com/hakanensari/peddler Not so clear on the 'client' creation they speak on. Anyone use this one before? Any help or direction is MUCH appreciated. Thanks Todd
ToddT
2

votes
1

answer
35

views

Formatting JSON in post

I need to send the id and quantity as an integer. I define it as an integer, but for some reason when I try and post it, it posts the id as a string. I'm missing something easy here, just no idea what.. How can I send both id and quantity as an integer? My code is below: var id = parseInt(identifier...
ToddT
3

votes
1

answer
156

views

Compare an array of hashes against each other, both ways

Adding this because some folks didn't see what I was asking for, but I'm looking for the unique values in each array, as compared to the other array. I need to find the differences between saved_start and incoming_start, but also between incoming_start and saved_start. saved_start is the result of a...
ToddT
0

votes
0

answer
39

views

Can I select a form by its action? [duplicate]

This question already has an answer here: Select elements by attribute 13 answers I am trying to bind an event handler to a form. The problem is I don't control the liquid/HTML this is written in. I just have access to it. Because of this the form could have any id or class but will always have the...
ToddT