...issue but it turns crazy if you try to include associated models deeper than 1 level: options = params.merge(:include => { :user => :avatar }) Post.paginate options When inspecting the merged params you will...
...I've got this message because the RAM Quota was exceed: 2013-11-11 17:13:25 WARNING nova.compute.api [req-bdasdfas-f5d7-4fcd-bf1b-asdfasdf229e ba2c21dadasdfasdf1d6asdfasdfa0f bfe2db2aasdfasdfb8ea686asdfasdfb] Quota exceeded for...
...bfe2db2aasdfasdfb8ea686asdfasdfb, tried to run 1 instances. Cannot run any more instances of this type. 2013-11-11 17:13:25 INFO nova.api.openstack.wsgi [req-bd003113-f5d7-4fcd-bf1b-asdfasdf229e ba2c21dadasdfasdf1d6asdfasdfa0f bfe2db2aasdfasdfb8ea686asdfasdfb...
comment = Comment.build(title: 'Bikini Bottom', content: 'Burgers for free', user_id: 1) comment.valid? => true comment.save => ActiveRecord::InvalidForeignKey Exception
>> JSON.parse(json) JSON::ParserError: 757: unexpected token at '"foo"' from /.../gems/json-1.7.7/lib/json/common.rb:155:in `parse' from /.../gems/json-1.7.7/lib/json/common.rb:155:in `parse' from (irb):1 Why? The error above happens...
...Linux will only use swap if *no* other memory is available sudo sysctl vm.swappiness 1 # Linux will try to avoid swap whenever possible The default value of the swappiness parameter...
There are many fun Unicode characters like ▲ or ☯. You might be tempted to use them for graphical elements in lieu...
...load a User and change both its group and its group_id: user = User.find(1) user.group = Group.find(3) user.group # returns # user.group_id = 4 user.group_id # returns 4 user.save
...highlights in a Google Groups post that the release is not backwards compatible to 1.x versions of Capybara does not support Ruby 1.8.x anymore removes confusion with Rails...
rescue RestClient::ResourceNotFound => error @retries ||= 0 if @retries < @max_retries @retries += 1 retry else raise error end end response end This snippet tries to re-send the...
Create a 1 GB file to swap to (we have sufficient space on / on this machine. Use a different partition if necessary) sudo dd if=/dev/zero of=/var/swapfile bs=1M...
If you prefer 2GB swap, chose count=2048, 4GB: count=4096 Change permissions of swap file: sudo chmod 0600 /var/swapfile Set up swap file and enable it:
...that Jasmine syntax has changed with Jasmine 2, so if you're using Jasmine 1.x you might instead want to use an older cheat sheet. Expectations # RSpec
...ID and title of the Pivotal Tracker story you're working on. For example: [#12345] Add Google Maps to user profiles Optional further commit messages in the body
# Only return nodes that are either elements or non-empty text nodes @nodeType == 1 || (@nodeType == 3 && _.strip(@nodeValue) != '') ).last() if $lastContent.get(0) == $lastChild.get(0) findLastLeaf($lastChild) else $container
...states = Array.wrap(state_or_states).map(&:to_s) state_or_states = state_or_states.first if state_or_states.size == 1 { :conditions => { :state => state_or_states...
...the blank form on top with the following snippet: actors = movie.actors actors.build actors.unshift(actors.pop(1)) # won't work with Rails 4+ Because build_for_form creates new objects and appends...
If you use Angular 1.4+ together with Angular Animate, all ng-show, ng-hide, ng-class etc. are animated on default. If you want only some elements to be animated...
...enable animations globally and add a certain class if no animation is wanted. Option 1: Enable animations only for html elements with class 'animate' @app.config ['$animateProvider', ($animateProvider) -> $animateProvider.classNameFilter(/\banimate\b...
...using in_groups_of and writing multiple column sets of your data (i.e. split 1 block of 3 columns and 100000 rows into 4 blocks of 3 (12 in total...
...install the last supported version of Bundler for Ruby < 2.3: gem install bundler -v '~>1' You will also see an error if your RubyGems version is...
After my update from MacOS X 10.6 Snow Leopard to 10.7 Lion the search function in Apple Mail stopped working. There were no or too little search results, when I...
...After the rebuild you should get the right search results again. Proceed with Step 1-2 for all your mailboxes (also for every top-level folder that is stored under...
...enable this, add an initializer config/initializers/array_paginate.rb: require 'will_paginate/array' You can now say: > numbers = (1..1000).to_a > page = numbers.paginate(:page => 2, :per_page => 10) => [11, 12, 13, 14, 15...
...16, 17, 18, 19, 20] > page.total_entries
Assuming you're wanting to undo the effects of git rm or rm followed by git add -A or something...
From Ubuntu 17, rbenv fails to install Ruby below 2.4 because of a mismatching OpenSSL dependency: it needs libssl1.0-dev for the installation process, but recent Ubuntus come with libssl-dev...
...instead of the current upstream version (which is 7). Install Ruby like this: # Ruby 1.8.7 apt install libssl1.0-dev # This will remove libssl-dev CONFIGURE_OPTS="--with-readline-dir=/usr/include/readline --with...
...that were modified in the last 24 hours you can do this: find . -mtime 1 You can also refer to another file's timestamp like this: find . -cnewer other_file...
...for a control to respond to touch commands. This is true for both iPad 1 and iPad 2 models. While certain CSS styles can lead to performance issues, removing those...