Skip to content

Instantly share code, notes, and snippets.

View foxweb's full-sized avatar
🏠
Working from home

Aleksey Kurepin foxweb

🏠
Working from home
View GitHub Profile
class PostsController < ApplicationController
# GET /posts
# GET /posts.xml
def index
@posts = Post.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @posts }
end
function checkRequiredPayments() {
$('input.payment_sum_field').each(function() {
if ($(this).hasClass("required")) {
var tr = $(this).parents("tr");
var checkbox = $("input[type=checkbox]:first", tr);
if (!checkbox.attr("checked")) {
checkbox.attr("checked", true);
}
var re = new RegExp("r_([0-9]+)");
var week_days = ['', 'понедельникам','вторниками','средам','четвергам','пятницам','субботам','воскресеньям'];
nsMain.OrderForm = Ext.extend(Ext.form.FormPanel, {
initComponent: function(){
var old_delivery_type;
var old_delivery_city;
var old_delivery_country;
var old_delivery_metro;
Ext.apply(this, {
url: '/office/server/callcenter/server.php',
if defined?(Object::RedCloth) and (!RedCloth.instance_methods.include?(:stock_pgl))
# RuTils выполняет перегрузку Textile Glyphs в RedCloth, перенося форматирование спецсимволов на Gilenson.
class ::Object::RedCloth < String #:nodoc:
# Этот метод в RedCloth при наличии Гиленсона надо отключать
alias_method :stock_htmlesc, :htmlesc
def htmlesc(text, mode=0) #:nodoc:
RuTils::overrides_enabled? ? text : stock_htmlesc(text, mode)
end
if defined?(Object::RedCloth) and (!RedCloth.instance_methods.include?(:stock_pgl))
# RuTils выполняет перегрузку Textile Glyphs в RedCloth, перенося форматирование спецсимволов на Gilenson.
class Object::RedCloth < String #:nodoc:
# Этот метод в RedCloth при наличии Гиленсона надо отключать
alias_method :stock_htmlesc, :htmlesc
def htmlesc(text, mode=0) #:nodoc:
RuTils::overrides_enabled? ? text : stock_htmlesc(text, mode)
end
class CreateVisaforms < ActiveRecord::Migration
def self.up
create_table :visaforms do |t|
t.string :lastname #1
t.string :lastname_prev #2
t.string :firstname #3
t.date :birth_date #4
t.string :birth_place #5
t.string :birth_country #6
@foxweb
foxweb / gist:713493
Created November 24, 2010 11:04
show.html.erb
<p id="notice"><%= notice %></p>
<p>
<b>Lastname:</b>
<%= @request.lastname %>
</p>
<p>
<b>Lastname prev:</b>
<%= @request.lastname_prev %>
class Request < ActiveRecord::Base
validates_length_of :lastname, :minimum => 2
validates_length_of :lastname_prev, :minimum => 2, :allow_blank => true
validates_length_of :firstname, :minimum => 2
belongs_to :birth_country_rel, :class_name => 'Country', :foreign_key => :birth_country
belongs_to :national_rel, :class_name => 'Country', :foreign_key => :national
belongs_to :birth_national_rel, :class_name => 'Country', :foreign_key => :birth_national
belongs_to :country_start_rel, :class_name => 'Country', :foreign_key => :country_start
belongs_to :country_dest_rel, :class_name => 'Country', :foreign_key => :country_dest
end
class NewsController < ApplicationController
def index
@news_pages, @news = paginate :news, :order_by => 'created_at desc', :per_page => 5
respond_to do |format|
format.html
format.plist { render :xml => array_to_plist(@news) }
end
end
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<!-- The <data> element below contains a Ruby object which has been serialized with Marshal.dump. -->
<data>
BAhvOglOZXdzCzoaQHBpY3R1cmVfdGhyZWVfbmVlZGVkRjoWQGF0dHJpYnV0ZXNfY2Fj
aGV7ADoYQHBpY3R1cmVfdHdvX25lZWRlZEY6EEBhdHRyaWJ1dGVzexAiFXBpY3R1cmVf
Zm91cl9leHQwIg9jcmVhdGVkX2F0IhgyMDEwLTAyLTE4IDEwOjU4OjUzIhpwaWN0dXJl
X3R3b19vcmlnX25hbWUwIglib2R5IgICBtCf0YDQtdC00LvQsNCz0LDQtdC8INCS0LDQ