Skip to content

Instantly share code, notes, and snippets.

View kagemusha's full-sized avatar

Michael kagemusha

View GitHub Profile
@kagemusha
kagemusha / gist:3161949
Created July 23, 2012 04:16
Rails Turn Off Annoying asset loaded msgs
c. Rails 3.2.6
In development.rb:
config.assets.debug = false
@kagemusha
kagemusha / gist:2918720
Created June 12, 2012 17:04
Metaget a Rails class with constantize
c. Rails 3.x
e.g. for a model User
class_name = "User"
klass = class_name.constantize
klass.find some_id
@kagemusha
kagemusha / gist:2918015
Created June 12, 2012 14:56
rspec troubleshooting
make sure database is clean, as sometimes causes funny errs if not
- e.g. was trying to create objs, but failed silently on a uniqueness constraint, so bombed when supposedly created models asked for their ids
@kagemusha
kagemusha / gist:2853186
Created June 1, 2012 16:00
Custom Domain Heroku
Ref: https://devcenter.heroku.com/articles/custom-domains
For naked domains, fairly simple:
1. Add domain to heroku
$ heroku domains:add www.example.com
2. Add separate A records for each of the following addresses using your DNS management tool (e.g. at godaddy or where your domain name hosted):
75.101.163.44
@kagemusha
kagemusha / gist:2781562
Created May 24, 2012 13:31
TypeError: Cannot visit...(Rails)
Version: Rails 3.2.1
TypeError: Cannot visit Videoset
Happens when specify class for id in validations (perhaps other places), e.g.:
INCORRECT
validates_uniqueness_of :song_num, :scope=>[:videoset]
CORRECT
validates_uniqueness_of :song_num, :scope=>[:videoset_id]
@kagemusha
kagemusha / gist:2732293
Last active October 5, 2015 01:28
Create new Rails App with Rails App Composer
Install: gem install rails_apps_composer
Create app example:
rails_apps_composer new atm -r devise git haml heroku rails_admin rspec sass seed_database add_user home_page
List Recipes: rails_apps_composer list
Additional Steps
- gemfile
- If using pg: create db
@kagemusha
kagemusha / gist:2225160
Created March 28, 2012 10:01
Rails 3.x ActionView::MissingTemplate for JSON
ActionView::MissingTemplate (Missing template...)
To fix this, make sure have a render such as:
format.json { render :json=>json_to_render }
If leave out the :json=> will get error
Seems if just do respond_to :json and return @someObj will get error
@kagemusha
kagemusha / gist:2156971
Created March 22, 2012 08:06
Malformed attribute block
This seems to come from haml.js
Not sure the quintessential case, but I had problems when calling JSON.stringify with a string with an apostrophe in in. Apparentely JSON.stringify can't handle apostrophes.
@kagemusha
kagemusha / gist:2090705
Created March 19, 2012 02:14
JQueryMobile: Link callbacks when href='#'
Circa: 1.1.0rc1
If have href='#', e.g. %a{href: '#', id: 'mylink'}, jqm will not fire an event so callback $('#mylink').click won't get called.
Instead do %a{href: 'javascript:myFunction()', ...}
Ref: http://forum.jquery.com/topic/how-can-i-create-buttons-that-execute-some-javascript-without-linking-to-any-address
@kagemusha
kagemusha / gist:2041160
Created March 15, 2012 01:52
Rails: Specify additional asset files for precompilation
Used on: Rails 3.2.1
If you have more than one set of assets to precompile, need to add using config.assets.precompile
E.g. if have mobile.css and mobile.js to precomp, do the following
In config/environments/production.rb (or whenver env you want precompiled)
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)