This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tested on: Rails 3.2.1 | |
Will get error if don't add :foreign_key to has_many side of relat: | |
e.g. | |
class Song < ActiveRecord::Base | |
belongs_to :creator, :class_name=>"User" #person who added song entry | |
class User < ActiveRecord::Base | |
has_many :created_songs, :class_name=>"Song", :foreign_key => 'creator_id' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url = location.href | |
e.g. to get anchor | |
anchor = location.href.split('#')[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails 3.2 | |
1. In initializers/mime_types.rb | |
2. Detection of Mobile Device | |
I put this is a file called mobile.rb in app/util | |
module Mobile | |
#optional for testing | |
TEST_MOBILE_DEV = false #set true to test on browser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |