This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SessionsHelper | |
def sign_in(user) | |
cookies[:user_id] = user.id | |
@current_user = user | |
end | |
def signed_in? | |
! @current_user.nil? | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SessionsHelper | |
def sign_in(user) | |
cookies[:user_id] = user.id | |
@current_user = user | |
end | |
def signed_in? | |
! @current_user.nil? | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Meeting < ActiveRecord::Base | |
has_many :participations, dependent: :destroy | |
has_many :players, through: :participations | |
belongs_to :place | |
attr_accessible :place_id, :name | |
end | |
class Participation < ActiveRecord::Base |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PostgreSQL. Versions 8.2 and up are supported. | |
# | |
# Install the pg driver: | |
# gem install pg | |
# On Mac OS X with macports: | |
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config | |
# On Windows: | |
# gem install pg | |
# Choose the win32 build. | |
# Install PostgreSQL and put its /bin directory on your path. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=form_tag('/meetings/filter_by_city', remote: true) do | |
=select("place", "city",options_for_select(@places), {}, onchange: 'this.form.submit()') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Place < ActiveRecord::Base | |
attr_accessible :address, :city, :name, :description | |
has_many :meetings | |
end | |
Class Meeting < ActiveRecord::Base | |
attr_accessible :start_at, :place_id, :title, :end_at | |
belongs_to :place | |
has_many :participations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE places ( | |
id integer NOT NULL, | |
address character varying(255) NOT NULL, | |
name character varying(255) NOT NULL, | |
city character varying(255) NOT NULL, | |
description character varying(255) NOT NULL, | |
); | |
CREATE TABLE meetings ( | |
id integer NOT NULL, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
validates :place_id, :title, :level, :start_at, :end_at, :presence => true | |
validates :start_at, :end_at, :inclusion => { | |
:in => DateTime.now.beginning_of_day..DateTime.now.end_of_month} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
validates :place_id, :title, :level, :start_at, :end_at, :presence => true | |
validate :event_takes_place_in_one_day, :event_is_not_in_past | |
def event_takes_place_in_one_day | |
self.start_at.day == self.end_at.day | |
end | |
def event_is_not_in_past | |
admissible_range = DateTime.now.beginning_of_day..DateTime.now.end_of_month | |
admissible_range.cover?(self.start_at) && admissible_range.cover?(self.end_at) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding:utf-8 | |
require 'spec_helper' | |
describe Front::BanksController do | |
before :all do | |
@bank = Bank.create!(:name => 'ПУ БАНКА РОССИИ N 10462', :bic => '040009002') | |
end | |
OlderNewer