Pergola
Names
- Taken
- ivy
- trellis
- grapevine
- chlorophyll
- vinify
Building the gem
- Ryan Bates you stud
- create the gem with builder before you create files within it.
Removing a file from Github
git rm examples/all.rbgit rm examples/all.rb --cachedleaves a local version
class << self
- see nice stackoverflow responses here and here
- katz write up
Reading
- http://www.gironda.org/2013/02/25/digging-in-the-vineyard-part-1.html
Calendar App 2
Active Admin
.powconfig
1 2 3 4 5 6 7 8 9 | |
Calendar App 1
Setup
- added a EventTimeValidator to lib. this needed to be updated in the app config file as well so that the autoload path would pick up the changes in the lib dir.
1 2 | |
Git global config github
- needed to link email from my new macbook
Uploads
- we used carrierwave
- remember to set multipart to true
Extend self
- from stackoverflow
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
Method Stubs
- A method stub is an implementation that returns a pre-determined value. Method stubs can be declared on test doubles or real objects using the same syntax.
1 2 3 | |
any_instance
- stub on any instance of a class
- Use
any_instance.stubon a class to tell any instance of that class to return a value (or values) in response to a given message. If no instance receives the message, nothing happens.
- Use
1 2 3 4 5 6 7 8 | |
Alias Attribute
alias_attribute :value, :url
Chop v. Chomp
- subtle difference between
chopandchomp
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Setting develop as the default
git branch --track develop origin/develop
Formtastic
- collection groups together elements for a select box
- include blank false
Deploying
- need to add new deploy instructions to .git/config file
Nano
- basic text editor that appears to be pre-loaded…
Offsetting an image and a link
- use padding to offset an image from its link
- I use this a lot when putting an icon in front of a link
- see here for more
Deploying to heroku
git push staging develop:master
Each with index
1 2 3 | |
S3
- used fog to store the carrierwave uploaded images on AWS
- needed to config heroku with the
heroku config:add ENV_VARIABLE=bucket-name -r stagingto make it work - in carrierwave.rb need to specify the
config.fog_host, but this is NOT the right method. It is supposed to beconfig.asset_host- implemented via this commit
- and corrected by
- also push the config variable via
heroku config:add CLOUDFRONT='<cloudfront URL>' -r staging
- also push the config variable via
- this post was helpful
xip.io
- Construct your xip.io domain by appending your application’s name to your LAN IP address followed by .xip.io. For example, if your development computer’s LAN IP address is 10.0.1.43, you can visit myapp.dev from another computer on your local network using the URL http://myapp.10.0.1.43.xip.io/. via
Sweepers and caching actions
caches_action :indexis all that is needed to cache an action viacache_sweeper :event_sweeperis added to the Events controller to trigger the sweeper…- Cache sweeping is a mechanism which allows you to get around having a ton of expire_{page,action,fragment} calls in your code. It does this by moving all the work required to expire cached content into an ActionController::Caching::Sweeper subclass. This class is an observer and looks for changes to an object via callbacks, and when a change occurs it expires the caches associated with that object in an around or after filter.
- Rails Guide
also need to turn on
config.cache_store = :dalli_store, ENV['MEMCACHE_SERVERS']In the context of ActiveAdmin
- We weren’t expiring the events index page, but were rather expiring the ActiveAdmin page instead. This solved the problem, but more specifically specifying the controller.
- see here
- We weren’t expiring the events index page, but were rather expiring the ActiveAdmin page instead. This solved the problem, but more specifically specifying the controller.
Another New MacBook Air Load
RBENV
- ran into a pow issue not recognizing my gemset -> similar issue to the one here and here.
- it ended up because I had installed rbenv with homebrew which meant it was in the opts directory. What a pain.
- the rbenv install went pretty smoothly save for that. Used [this as a guide](http://www.bounga.org/ruby/2012/02/06/pow-using-rbenv/.
PSQL
the install went much smoother this time. I used this ref when I ran into problems.
this helped on my old air… the app installed without a hitch, but I was missing the creating of the databases.
when the psql app wasn’t active
♕ psql psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket “/var/pgsql_socket/.s.PGSQL.5432”?
after turning it on, I got this
♕ psql psql: FATAL: database “Ajonas” does not exist
the PATH clearly isn’t right, but by adding
rake db:create:allI got the app to bootup.
Bundler and Octopress reinstall
- bundler wasn’t recognized because of the different ruby version. Installed the new version and
gem install bundleras [advised](http://stackoverflow.com/questions/7483515/rake-aborted-no-such-file-to-load-bundler-setup-rails-3-1.
KCA 4
Google Analytics
- We passed in the onclick trackers as options
- This the gem we used to install the UA code in the footer, also used this for reference.
Arel
- [Some cool arel queries](http://stackoverflow.com/questions/4402815/is-there-a-particularly-elegant-way-to-do-a-count-query-with-rails-3-arel.
- used a lamba as shown here, because otherwise the queries will be cached and we were running queries for a day to day basis.
- ARel has some good documentation.
Local Storage
- used store.js
- nice little screencast
- here is an older article from 2010
- NOTE: We ended up using store.js with json because ie7 apparently doesn’t come equiped with JSON. Tom and I broke our heads trying to figure out why
store.enabledwasn’ttruefor ie7. It came down to the fact that ie7 didn’t have JSON.
Thought this was a cool little way to store whether a td square had been clicked on…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
I think this was the first time I used the push method in coffeescript.
Z-index
- in order to use z-index you need to use the position absolute, relative, or fixed as mentioned here
SASS
>*selects all the elements in the selector
PG backups
- Backing up a larger DB on heroku -> docs
Anchor in a path helper
- pass it in as an option
redirect_to post_path(comment.post, :anchor => "comment-#{comment.id}")-> from
Regex
- remember there is no whitespacing in regex
background_\w|clicked_spacenotbackground_\w | clicked_space
Background images in mobile
- need to make sure to explicity define the background image and background size for mobile
KCA 3
Everytime you clone a project you get its full history…
- to get a specific commit
$ git checkout -b aNewBranch SHA1with SHA1 representing the commit id from which you want to proceed.
- to get a specific commit
config env variables on heroku
heroku config:add FACEBOOK_APP_TOKEN='<tokenhere>' --remote staging
rake deploy:stagingbut need to make sure staging db is up to daterake db:migrate RAILS_ENV=stagingcustom actions are for dream big are here
git bisect-> docs
Expect syntax
- remember to not including whitespaces between expect and the parentheses
- correct ->
expect(sm.current_number_of_boards).to eq 24 - incorrect ->
expect (sm.current_number_of_boards).to eq 24
- correct ->
Testing the cache
it’s not easy to test the cache.
- one problem is that when you write to the cache you are affecing the dev cache
can clear the cache with
Rails.cache.clearfound here
Progress bar
HAML
- partial ->
= render :partial => "partial_name" - yield ->
#masthead= yield :masthead - setting a variable in HAML ->
- check_mark = image_tag("http://placehold.it/21x21", class: 'check')need the- - submit button ->
%input{:type => "submit", :value => "Send", :class => "button"}
1 2 | |
There are a bunch in the docs.
Content_for
1 2 3 4 5 6 7 8 9 | |
Escaping a space
- ascii character in link_to, just add
.html_safe
Creating or updating many records at a time in rails
1 2 3 4 5 6 7 8 9 | |
Collection in routes
1 2 3 4 5 | |
.length
You can look for the number of instances in the DOM and update it accordingly if there are the right number. I used this when I was updating the DOM and to see if the page had 3 classes indicating that three friends had been nominated.
1 2 | |
Heroku console
heroku run rails console --remote <name of branch>orheroku run console -r <name of branch>for short
CSS Positioning
Print Stylesheets
- had a problem with getting the @media print file to recognize the sass styling that I was writing. Discovered that every single element needed to be to explicitly defined for it to work…. what a pain in the ass.
JQuery Migrate
- Was removed from the jquery core
Paypal Integration
IPN
instant payment notification
- Paypal will provide an asynch call made to our server from paypal to update us of the status.
- this is asynch so it could take a few seconds or it could take more.
KCA 2
Heroku
git push staging develop:master
FB
- target ‘_top’ will put the new window on top
http://app.facebook.com/name-space- make sure to disable secure browsing in FB
change fields from address
statetostate_locto avoid collisions with state machine gems like transitionscan simulate mobile with overrides in the inspector
heroku run rake db:migrate --remote stagingheroku config:add <env variable> <env variable>heroku log --remote staging.shufflemethod.floorreturns an integerif diving two integers you need to th make sure one of them is a float
In routes,
member doblock adds a resource on a specific record, while collect doin config/application.rb in order to load libs automatically need to change config to
config.autoload_paths += %W(#{config.root}/lib)has_mobile_fu falsein appcontroller, need false-
expose(:articles) { current_user.articles }scopes articles belonging to that user
output the boards on board show page, new board page, and how to play
-
- need to use .html_safe
to start memcache
/usr/local/opt/memcached/bin/memcacheddeploy to heroku staging with
git push staging develop:mastercreating a table with content tags in a helper
.update_attribute!versus.update_attribute-> raise an exception rahter than false.
Tests
- Make sure to migrate the Test DB ->
rake db:migrate RAILS_ENV=test watchr .watchr- using traits with Factory Girl
- expect syntax
- rake start to start spork
- {:id => board.id}.merge(opts)
HAML
= f.hidden_field :customer_id, value: @customer.idfrom- html to haml
1 2 | |
Makes divs with classes above
- HAML id and class declaration
- passing in partials with locals on stackoverflow
Ajax with coffeescript
Used the call below to make a friend request.
1 2 3 4 5 | |
The callback is to ensure that other function do not proceed before the friends are loaded asynchronously.
Auto-complete with JQuery UI
- Got it from here
- also loaded the js and css minified versions in the lib directory.
- there was a small change to be made, documented here
Javascript to coffee
Posting to a wall, note the method and the
:tomethod, taken mostly from here
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
= link_to "Something", some_path, :method => :postNeed to remember to add () after a method call
- defaults to auth user if no
to:method - discussion on lexical scope
Counter_cache
- In the model ->
belongs_to :project, :counter_cache => true - railscast #23
Jquery
$("div,p,span")this works as a multiple selector- hidden divs
Selecting a winner
- use the randumb gem
Migrate test db
ake db:migrate RAILS_ENV=test
No merge message for a no-ff flag
--no-edit
FB app auto-grow
Gem from a git url
gem 'redcarpet', :git => 'git://github.com/tanoku/redcarpet.git'
With an options hash
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
FB invite friends
1 2 3 4 5 6 7 | |
Delpoy
rake deploy:stagingandrake deploy:production