Skip to content

Instantly share code, notes, and snippets.

View richardsondx's full-sized avatar

Richardson Dackam richardsondx

View GitHub Profile
@richardsondx
richardsondx / index.html.erb
Created March 30, 2012 03:47
What's wrong with my if statement?
<% if micropost.to_guys == true %>
<li class="headshot"><%= image_tag("guys-head.png")%></li>
<%elsif%>
<li class="headshot"><%= image_tag("girl-head.png")%></li>
<%end%>
@richardsondx
richardsondx / _form1.html.erb
Created March 30, 2012 05:47
I have 2 forms, one using submit_tag and one using image_submit_tag. The controller recognize the params from the first form but not the second.
<%= form_for @micropost do |f| %>
<p>
<fieldset>
<legend> What's your Tip? </legend>
<%= f.text_field :content, :size => 90 %> <br/>
<%= f.label "Send this Tip:" %>
<%= submit_tag "to Guys" %>
<%= submit_tag "to Girls"%>
</p>
@richardsondx
richardsondx / Gemfile
Created March 30, 2012 21:10
issue with heroku
source 'https://rubygems.org'
gem 'rails', '3.2.1'
gem 'heroku'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
@richardsondx
richardsondx / gemfile
Created March 31, 2012 07:29
error while deploying app to heroku
source 'https://rubygems.org'
gem 'rails', '3.2.1'
gem 'heroku'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :production do
@richardsondx
richardsondx / Gemfile
Created March 31, 2012 22:26
issue while pushing to heroku - 2
source 'https://rubygems.org'
gem 'rails', '3.2.1'
gem 'heroku'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :production do
@richardsondx
richardsondx / post controller
Created April 2, 2012 04:08
the %Q{..} doesn't show the iframe. The html dom is being displayed on the view.
def youtube_embed(youtube_url)
if youtube_url[/youtu\.be\/([^\?]*)/]
youtube_id = $1
else
# Regex from # http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url/4811367#4811367
youtube_url[/^.*((v\/)|(embed\/)|(watch\?))\??v?=?([^\&\?]*).*/]
youtube_id = $5
end
%Q{<iframe title="YouTube video player" width="640" height="390" src="http://www.youtube.com/embed/#{ youtube_id }" frameborder="0" allowfullscreen></iframe>}
ruby-1.9.2-p180 :005 > Microspost.where(:id => (190..202).to_a).destroy_all)
SyntaxError: (irb):5: syntax error, unexpected ')', expecting $end
from /Users/Richardson/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.2.1/lib/rails/commands/console.rb:47:in `start'
from /Users/Richardson/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.2.1/lib/rails/commands/console.rb:8:in `start'
from /Users/Richardson/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.2.1/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
ruby-1.9.2-p180 :006 > Microspost.find__all
NameError: uninitialized constant Microspost
from (irb):6
@richardsondx
richardsondx / Pages _post.html.erb
Created April 3, 2012 03:29
Pagination with ajax+kaminari won't paginate @microposts block
<% for micropost in @microposts %>
<span class="article">
<ul>
<li class="headshot"><%= image_tag("#{ micropost.to_guys ? "guys" : "girl" }-head.png") %></li>
<li class="tipscontent"><p><%= link_to micropost.content, page_path(micropost) %></p></li>
<li class="fbshare">
<a href="https://twitter.com/share" class="twitter-share-button" data-via="twitterapi" data-lang="en" data-hashtags="hmdy">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
@richardsondx
richardsondx / Command I typed and flow
Created April 3, 2012 16:53
i followed railscast tutorial on how to install bootstrap and it bugged
$ rails new karret
$ rails g scaffold karretlink name link:string type:string description:string start_min:integer start_sec:integer --skip-stylesheets
$ rake db:migrate
# I made sure the page was working and displaying the scaffold then added the gems to gem file
$ bunddle install
@richardsondx
richardsondx / gist:2296159
Created April 3, 2012 22:59
error with rmagick
Installing rmagick (2.13.1) with native extensions /Users/Richardson/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/Users/Richardson/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of