Skip to content

Instantly share code, notes, and snippets.

View tammersaleh's full-sized avatar

Tammer Saleh tammersaleh

  • coreweave.com
  • California, USA
  • 18:21 (UTC -08:00)
View GitHub Profile
content platos_forms chrome/content/
overlay chrome://browser/content/browser.xul chrome://platos_forms/content/platos-forms.xul
skin platos_forms classic/1.0 chrome/skin/
style chrome://browser/content/browser.xul chrome://platos_forms/skin/toolbar-button.css
style chrome://global/content/customizeToolbar.xul chrome://platos_forms/skin/toolbar-button.css
- semantic_form_for @page do |form|
- form.inputs do
= form.input :url
- form.semantic_fields_for :notes, form.object.notes.build do |note_form|
= note_form.input :title
= note_form.input :body, :as => :text
def require_no_user
if current_user
store_location
flash[:notice] = "You must be logged out to access this page"
redirect_to root_url
return false
end
end
class ApplicationController < ActionController::Base
def current_user_session
# return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
def current_user
# return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.user
end
context "on POST to /user_session/create with good creds" do
setup do
assert_nil UserSession.find
assert_nil @controller.send(:current_user)
@user = Factory(:user, :password => "foobar")
post :create, :user_session => { :email => @user.email, :password => "foobar" }
end
# should_redirect_to("homepage") { root_url }
should_set_the_flash_to /welcome/i
end
class Account < ActiveRecord::Base
has_many :users
has_many :account_admin_permissions
end
@account.users.admins
# avoids mass-assignment restriction for protected attributes
def update_from_hash!(params)
params.each {|method,value| self.send("#{method}=", value)}
self
end
tsaleh@mommysgaragesale:/home/mgs_production/sites/mgs/releases$ ls
20081010085631 20081010155749 20081013035601 20081015052243 20081015085819
20081010090902 20081013035444 20081013050138 20081015052428 20090611220654
tsaleh@mommysgaragesale:/home/mgs_production/sites/mgs/releases$ sudo tail -n 0 -f */log/production.log /var/log/nginx/*.log
==> 20081010085631/log/production.log <==
==> 20081010090902/log/production.log <==
==> 20081010155749/log/production.log <==
def cookies
return {} unless @env["HTTP_COOKIE"]
if @env["rack.request.cookie_string"] == @env["HTTP_COOKIE"]
@env["rack.request.cookie_hash"]
else
@env["rack.request.cookie_string"] = @env["HTTP_COOKIE"]
# According to RFC 2109:
# If multiple cookies satisfy the criteria above, they are ordered in
# the Cookie header such that those with more specific Path attributes
{:one => 1, :two => 2}.select {|k,v| k == :one} #=> [[:one, 1]]