Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am ancyentmariner on github.
  • I am jeffkingswood (https://keybase.io/jeffkingswood) on keybase.
  • I have a public key ASB_cowqjh25uom3rckRwBkSmGoEt_PLuiKqdtV9XcEJxAo

To claim this, I am signing this object:


author: Jeff Kingswood title: SEO Tips and Tricks for Vue Single Page Apps image: blog/generic/image/vue-js.jpg thumbnail: blog/generic/image/vue-js.jpg featured_thumbnail: blog/generic/thumbnail/vue-js.png thumbnail_background: '#28a46e' excerpt: How to manage SEO in Vue single page apps. date: 2019-05-01 tags: development, tech

Vue.js Code Recipe: Building Rails Params with Computed Properties

Rails is kinda like that friend you have who's really into foreign films. It knows what it likes and is very picky about what it will accept. Especially with params. If you build your param hashes out correctly in rails, life is swell. Submitting forms is a breeze. You can instantiate a new object, feed it params, and let rails sort out the rest. But if you don't build out the data for params correctly, submitting forms and updating objects in you db is a royal pain.

Building the correct data structure for params is easy enough with erb or some other rails templating language that builds out html. But what if you are using one of these modern front end frameworks to build you app is javascript? Gasp! Don't tell DHH!

Let's look at a pattern that we have come up with here at Littlelines to build out params hashes that play nice with rails using the Vue framework's computed property functionality.

First a little bit about computed prope

### Keybase proof
I hereby claim:
* I am ancyentmariner on github.
* I am ancyentmariner (https://keybase.io/ancyentmariner) on keybase.
* I have a public key ASBe9M7f0TfVYfA0aj8rr9yxiYAnbUpDTHBbq3ZLZYIrtAo
To claim this, I am signing this object:
@AncyentMariner
AncyentMariner / flatten_arbitrary_array.js
Last active December 6, 2016 02:54
Flatten an array in javascript
//Write some code, that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers.
//e.g. [[1,2,[3]],4] -> [1,2,3,4].
const flatten_list = list => list.reduce(
(a, b) => a.concat(Array.isArray(b) ? flatten_list(b) : b), []
);