Posts

Rails 5 nested form won't create child records -

i've been stuck on hours. don't understand how nested forms , using 'accepts_nested_attributes_for' supposed work. i have 'form_for' new list, , 'fields_for' it's list_items. here fields_for list_items. fields_for :list_items https://pastebin.com/nxzwgeyj now, 'list_item' :through part of list's has_many_through associations user's 'user_items'. nested form supposed submit information 'user_item' needed build 'list_item' belong new list. seems somewhere along way parameters child items not being delivered... started post "/list" 127.0.0.1 @ 2017-08-17 18:18:04 -0400 processing listscontroller#create html parameters: {"utf8"=>"✓", "authenticity_token"=>"203d1bpqzzku9j0gyupovqnfbkxmreydlmb4idaradnjvx5fqcydg5due/d2ngwocu6afkc+hwl5qcpfu9glqw==", "list"=>{"name"=>"", "list_items_attributes"=>{...

Using Square Connect PHP SDK, UpsertCatalogObject fatal error -

i using square connect php sdk, , getting following error, , haven't been able find solution. trying push few new categories have been added on app (within mysql database). building catelogobject foreach ($push_array $key => $cat_name) { $category = $this->products_lib->get_category($cat_name); $idempotency_key = uniqid('',true); $push_obj = new stdclass(); $push_obj->type = 'category'; $push_obj->id = '#' . trim($category->name); $push_obj->category_data = ['name'=>trim($category->name)]; $push_obj->present_at_all_locations = true; $catelogobject = ["idempotency_key" => $idempotency_key, 'object' => $push_obj]; print_r($catelogobject); $response = $square_connect->upsert_category($catelogobject); } produces ( [idempotency_key] => 5996186208eae4.27853833 [object] => stdclass object ( [type] => category ...

arrays - PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" -

i running php script, , keep getting errors like: notice: undefined variable: my_variable_name in c:\wamp\www\mypath\index.php on line 10 notice: undefined index: my_index c:\wamp\www\mypath\index.php on line 11 line 10 , 11 looks this: echo "my variable value is: " . $my_variable_name; echo "my index value is: " . $my_array["my_index"]; what these errors mean? why appear of sudden? used use script years , i've never had problem. what need fix them? this general reference question people link duplicate, instead of having explain issue on , on again. feel necessary because real-world answers on issue specific. related meta discussion: what can done repetitive questions? do “reference questions” make sense? notice: undefined variable from vast wisdom of php manual : relying on default value of uninitialized variable problematic in case of including 1 file uses same variable name. majo...

google maps - Use numbers instead of alphabet for DirectionsRenderer api Markers -

i display direction on google map markers i'm having trouble change alphabet inside of markers numbers. my method looks like, directiondisplay(direction) { this.directionsrenderer = new google.maps.directionsrenderer({ preserveviewport: true }); this.directionsrenderer.setmap(this.props.map); return this.directionsrenderer.setdirections(direction); } and using it directionsservice.route({ origin, destination, waypoints, optimizewaypoints: true, travelmode: this.props.maps.directionstravelmode.driving }, (result, status) => { if (status == this.props.maps.directionsstatus.ok) { this.directiondisplay(result); } else { console.error(`error fetching directions ${result}`); } }); i tried this.directionsrenderer = new google.maps.directionsrenderer({ preserveviewport: true, markeroptions: {label: '1'} }); '1' overlays on alphabets instead of replacing them. does know how figure out? thank you,

postgresql - relative position of digits and ':' in postgres collating sequence -

say have table 't1' string column 'name'. , have names 'n1','n2','n9' , 'n:'. if do select * t1 orderby name asc i expect n1 n2 n9 n: given ':' comes after '9' in ascii, instead, get n: n1 n2 n9 which surprise. there need 'use ascii collating sequence basic ascii chars' from experience, collation issue select * t1 order name collate "posix"; this list of exapmle collations in case collation have listed, sql_latin1_general_cp850_bin not work https://www.postgresql.org/docs/9.1/static/collation.html

java - How do I know if my LinkedList is already ordered? -

this question has answer here: how determine if list sorted in java? 11 answers private static linkedlist<integer> melhormoto1 = new linkedlist<>(); i know can create new linkedlist, use newlinkedlist = melhormoto1; and collections.sort(newlinkedlist); , newlinkedlist.equals(melhormoto1 ); i'm working recursive function, newlinkedlist = melhormoto1; slow attribution. can check if linkedlist ordered method or something? in java 8, can use comparators.isinorder(iterable) achieve list (or other ordered collection). prior java 7, yourself: check list sorted in ascending order, iterate through , check current element cur greater or equal previous element prev each adjacent pair of elements. change less or equal descending order. requires size() - 1 total checks.

php - Im trying to generate a unique hash for all the users -

i'm trying generate unique hash users in database; here code: <?php include("php/connect.php"); $sql = "select id user"; while ($id = mysqli_fetch_assoc(mysqli_query($conn, $sql))) { $new_hash = md5(uniqid(rand(), true)); $sql2 = "insert user (hash) value ('$new_hash') id = $id['id']"; mysqli_query($conn, $sql2); } ?> every time run it, following error: fatal error: maximum execution time of 30 seconds exceeded in regarding query: $sql2 = "insert user (hash) value ('$new_hash') id = $id['id']"; insert doesn't use where clause, update does, insert ... on duplicate key update . however, don't know why you're wanting that. using column set auto_increment should ample have unique id. yet, if want do, need use 1 of methods shown above. mysqli_error($conn) way, have thrown syntax error this. i.e.: if(!$sql2){ echo "error: " . ...