Skip to content

Instantly share code, notes, and snippets.

View joemsak's full-sized avatar

Joe Sak joemsak

View GitHub Profile
def create
@work = Work.new(:swfupload_file => params[:Filedata])
if @work.save
render :partial => 'work', :object => @work
else
render :text => "error"
end
end
#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
<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 -%>
class RssReader
require 'timeout'
def self.posts_for(feed_url, length=2, perform_validation=false)
posts = []
retries = 42
begin
Timeout::timeout(5){
git clone git://github.com/activefx/restful_authentication_tutorial.git
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
script/generate model photo gallery_id:integer
script/generate paperclip photo image
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']
require 'digest/sha1'
class User < ActiveRecord::Base
# ...
has_many :galleries
# ...
end
script/generate controller photos create update destroy