Skip to content

Instantly share code, notes, and snippets.

Avatar

Joe Sak joemsak

View GitHub Profile
View gist:99574
def create
@work = Work.new(:swfupload_file => params[:Filedata])
if @work.save
render :partial => 'work', :object => @work
else
render :text => "error"
end
end
View gist:168836
#views/root/index.html.erb
<%= link_to 'Home', root_path, :class => 'hide ' + is_page?('root'), :id => 'nav-home' %>
#application_helper.rb
def is_page?(t)
return 'here' if t == params[:controller]
return 'menu'
end
#error resolved!
View gist:174175
#view
<div id="twitter">
<h3 class="hide">Recent Tweets</h3>
<ul>
<% @tweets.each do |tweet| -%>
<li class="tweet">
<%= tweet.title.gsub!('simplifyadvance: ', '') %>
<strong class="date"><%= tweet.pubDate.strftime("%l:%M %p %b %e") %></strong>
</li>
<% end -%>
View gist:174283
class RssReader
require 'timeout'
def self.posts_for(feed_url, length=2, perform_validation=false)
posts = []
retries = 42
begin
Timeout::timeout(5){
View gist:189148
git clone git://github.com/activefx/restful_authentication_tutorial.git
View gist:189149
class Gallery < ActiveRecord::Base
belongs_to :user
has_many :photos, :dependent => :destroy
validates_presence_of :title
acts_as_urlnameable :title, :overwrite => true
def to_param
urlname
end
end
View gist:189151
script/generate model photo gallery_id:integer
script/generate paperclip photo image
View gist:189152
class Photo < ActiveRecord::Base
belongs_to :gallery
has_attached_file :image,
:styles => { :large => "640x480>",
:medium => "150x150#",
:thumb => "75x75#" }
validates_attachment_presence :image
validates_attachment_content_type :image,
:content_type => ['image/jpeg', 'image/jpg']
View gist:189153
require 'digest/sha1'
class User < ActiveRecord::Base
# ...
has_many :galleries
# ...
end
View gist:189155
script/generate controller photos create update destroy