Ruby and jQuery cheat sheets

11/09/14  Public, Cheat Sheets

Ruby: http://overapi.com/ruby/

jQuery: http://overapi.com/jquery/

Great site. Also contains cheat sheets for Git, HTML, MySQL, JavaScript and more.

1 vote - harrylevine

Using jQuery to return which item is selected in a group of radio buttons, in a form

11/10/14  Public, Other Languages

Here is a snippet of code from a form for a group of radio buttons:

<p>Age group:</p>
<label><input type="radio" id="age0" name="age" value="-30" /> under 30</label>
<label><input type="radio" id="age1" name="age" value="30-50" check...

1 vote - harrylevine

Using jQuery to determine if a checkbox from a form is or is not checked

11/08/14  Public, Other Languages

Here is a snippet of code from a form for a checkbox with a label:

<label><input type="checkbox" id="like" name="like" checked="checked" /> I like jQuery</label>

This line of jQuery will determine if the box is checked, and log...

1 vote - harrylevine

Using jQuery to determine if an item from a form's drop-down menu is or is not selected

11/08/14  Public, Other Languages

Here is a snippet of code from a form for a drop-down menu containing choices:

<select id="skills" name="skills">
  <option value="none">please select&hellip;</option>
  <option value="html">HTML</option>
  <option value="css">CSS</...

1 vote - harrylevine

Tool to help learn and understand CSS selectors

11/08/14  Public, Online Resources, Other Languages

http://selectorgadget.com/

This tool will tell you the CSS selectors you will need in order to target an area or areas of your page. This applies directly to writing CSS and to writing jQuery.

Can be installed as a Chrome extension, or a bo...

1 vote - harrylevine

mangling arrays

11/07/14  Public, Tricks, Ruby General

To take an array like:

[1, 3, 'two', 5]

and have it result in an array of pairs such as:

[[1, 3], 'two', 5]]

You can use each_slice method.

array.each_slice(2)

Provided, of course, that array is assigned the original ...

2 votes - kotp

Determine what gems in your project have newer versions available

11/08/14  Public, Rails General, Gems

Run bundle outdated

To help decide if you want to take action and update a particular gem, view the gem's changelog.

For example, if there is an updated version of Devise available, Google devise changelog to determine what has been ch...

1 vote - harrylevine

Updating Rails version for a patch update, i.e. from 4.1.1 to 4.1.7

11/07/14  Public, Command Line, Rails General, Gems

  • Create a new branch
  • update the gemfile to gem 'rails', '4.1.7'
  • run bundle
  • this may show conflicts in other rails dependencies like
    • actionview, actionpack, actionmodel, etc
  • in order to update these Rails associated items, and...

1 vote - harrylevine

Rails command for generating a Model with columns and references

10/30/14  Public, Command Line, Rails General

$ rails generate model User name:string age:integer vote:references post:references

the model name is Capital and singular (i.e. User)

Use vote:references and post:references in your generator to add the foreign IDs into User table, to...

1 vote - harrylevine