Skip to content

Instantly share code, notes, and snippets.

View diegorv's full-sized avatar

Diego Rossini diegorv

View GitHub Profile
class PasteController < ApplicationController
before_filter :last_pastes
private
def last_pastes
@last_pastes = Paste.last_pastes
end
public
class PasteController < ApplicationController
before_filter :last_pastes
private
def last_pastes
@last_pastes = Paste.last_pastes
end
public
# Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
class Poller
def self.call(env)
if env["PATH_INFO"] =~ /^\/poller/
@posts = Post.find(1, :select => "title")
[200, {"Content-Type" => "text/html"}, @posts.title]
else
[404, {"Content-Type" => "text/html"}, ["Not Found"]]
# Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
class Poller
def self.call(env)
if env["PATH_INFO"] =~ /^\/poller/
@post = Post.find(1)
[200, {"Content-Type" => "text/html"}, @post.title]
else
[404, {"Content-Type" => "text/html"}, ["Not Found"]]
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
class Poller
def self.call(env)
if env["PATH_INFO"] =~ /^\/poller/
@post = Post.find(1)
ActiveRecord::Base.clear_active_connections!
[200, {"Content-Type" => "text/html"}, @post.title]
else
[404, {"Content-Type" => "text/html"}, ["Not Found"]]
map.resources :editions, :as => "edicao" do |edition|
edition.resources :categories, :as => "caderno" do |category|
category.resources :articles, :as => "artigo" do |article|
article.resources :article_comments, :as => "comentarios"
article.resources :article_ratings, :as => "ratings"
end
end
end
class Article < ActiveRecord::Base
has_permalink :title
belongs_to :category
has_attached_file :image, :styles => { :thumb => "100x100>" }
def to_param
"#{permalink}"
end
class ProjectsController < ApplicationController
# TODO refactor these before filters, sometimes they do the same check multiple times
before_filter :login_required, :only => [:new, :create, :index, :edit, :update, :destroy]
before_filter :fetch_current_project, :except => [:new, :create, :index]
before_filter :owner_required, :except => [:new, :create, :index, :show]
def index
@projects = current_user.projects.paginate(:per_page => 10, :page => params[:page])
end
class TodosController < ApplicationController
helper :todos
skip_before_filter :login_required, :only => [:index, :calendar]
prepend_before_filter :login_or_feed_token_required, :only => [:index, :calendar]
append_before_filter :init, :except => [ :destroy, :completed, :completed_archive, :check_deferred, :toggle_check, :toggle_star, :edit, :update, :create, :calendar ]
append_before_filter :get_todo_from_params, :only => [ :edit, :toggle_check, :toggle_star, :show, :update, :destroy ]
session :off, :only => :index, :if => Proc.new { |req| is_feed_request(req) }
<div id="display_box">
<div id="projects-empty-nd" style="<%= @no_projects ? 'display:block' : 'display:none'%>">
<div class="message"><p>Currently there are no projects</p></div>
</div>
<%= render :partial => 'project_state_group', :object => @active_projects, :locals => { :state => 'active'} %>
<%= render :partial => 'project_state_group', :object => @hidden_projects, :locals => { :state => 'hidden'} %>
<%= render :partial => 'project_state_group', :object => @completed_projects, :locals => { :state => 'completed'} %>
</div>
<% @project = @new_project -%>