Ryan Perera

1

votes
1

answer
1.3k

views

Whats the most efficient way to update a partial after an AJAX form submit in Rails 3

I have a page with code as follows: where form is a form for '@item' and 'render @item' renders a partial that represents '@item'. The form uses remote: :true and submits using AJAX. Whats the simplest and most efficient way in rails 3 to update the entire @item partial when the form is submitted.
Ryan Perera
1

votes
6

answer
674

views

Best way to merge key value pairs in a hash based on number of values for that key in Ruby

I have a hash of arrays in ruby as : @people = { 'a' => ['john', 'mark', 'tony'], 'b'=> ['tom','tim'], 'c' =>['jane'], 'others'=>['rob', 'ryan'] } I would like to merge all key value pairs where there are less than 3 items in the array for a particular keys values. They should be merged into the ke...
Ryan Perera
4

votes
5

answer
675

views

Whats the best way to split an array in ruby into multiple smaller arrays of random size

I have multiple arrays in ruby of variable length from 1 to 40 : @items is a typical array which could be anywhere from 1 to 40 in length. eg @items = [1, 2, 3, 4, 5, 6] I want to randomly split the array into smaller arrays of lengths either 1, 2 or 3 to give a result of (for example) @items = [[1,...
Ryan Perera
3

votes
2

answer
4.9k

views

How to Pull from github and keep local file without resolving merge conflicts

I want to pull from the github master full to update my current working directory. There is a file i've worked on called form.html which exists in my working directory and an older version on the github origin master branch. git pull origin master When pulling from the master Im asked to resolve con...
Ryan Perera