This file contains 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
\flashcards\app\models\card.rb | |
============================ | |
class Card < ActiveRecord::Base | |
def set_review_date | |
review_date = DateTime.now + 3.days | |
logger.debug "def set_review_date from debug" | |
logger.info "def set_review_date from info" | |
end |
This file contains 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 Card < ActiveRecord::Base | |
def set_review_date | |
self.review_date = DateTime.now + 3.days | |
logger.debug "def set_review_date from debug" | |
logger.info "def set_review_date from info" | |
end | |
logger.debug "before_validation :set_review_date from debug" | |
logger.info "before_validation :set_review_date from info" |
This file contains 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 EqualValidator < ActiveModel::Validator | |
def validate(card) | |
Rails.logger.info "validates" | |
if ((card != nil) && (card.original_text != nil) && (card.translated_text != nil) && (card.review_date != nil)) | |
if card.original_text.downcase == card.translated_text.downcase | |
translated_text.errors[:base] << "The values of original text and translated text should be different" | |
end | |
end | |
end | |
end |
This file contains 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
Started GET "/cards/16" for 10.0.2.2 at 2015-11-03 01:30:49 +0400 | |
Processing by CardsController#show as HTML | |
Parameters: {"id"=>"16"} | |
Card Load (1.9ms) SELECT "cards".* FROM "cards" WHERE "cards"."id" = $1 LIMIT 1 [["id", 16]] | |
Rendered cards/show.html.erb within layouts/application (1.5ms) | |
Completed 200 OK in 199ms (Views: 161.8ms | ActiveRecord: 1.9ms) | |
Started GET "/assets/application.css?body=1" for 10.0.2.2 at 2015-11-03 01:30:49 +0400 |
This file contains 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
<head> | |
<title>Cards</title> | |
<link rel="stylesheet" href="application.css"> | |
</head> | |
<h1>Listing cards</h1> | |
<table> | |
<tr> | |
<th>Original Text</th> |
This file contains 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
Rails.application.routes.draw do | |
resources :cards | |
get "/" => "home#index" | |
post "/cards/new" => "cards#create" | |
end | |
# get "home" => "home#index" | |
# The priority is based upon order of creation: first created -> highest priority. |
This file contains 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
require "nokogiri" | |
require "open-uri" | |
page = Nokogiri::HTML(open("http://lingvotutor.ru/1500-samyx-upotreblyaemyx-slov-k-toefl")) | |
word_list = [] | |
page.search("tr")[0].each do |row| | |
original = row.css('th')[0].content | |
translated = row.css('th')[0].content |
This file contains 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
vagrant@precise32:/vagrant/flashcards$ rake db:seed --trace | |
** Invoke db:seed (first_time) | |
** Execute db:seed | |
** Invoke db:abort_if_pending_migrations (first_time) | |
** Invoke environment (first_time) | |
** Execute environment | |
** Execute db:abort_if_pending_migrations | |
rake aborted! | |
NoMethodError: undefined method `css' for ["class", "column-1"]:Array | |
/vagrant/flashcards/db/seeds.rb:9:in `block in <top (required)>' |
This file contains 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
require "nokogiri" | |
require "open-uri" | |
page = Nokogiri::HTML(open("http://lingvotutor.ru/1500-samyx-upotreblyaemyx-slov-k-toefl")) | |
word_list = [] | |
page.search("table.tablepress tablepress-id-579")[0].each do |row| | |
original = row.css('th.column-1')[0].text | |
translated = row.css('th.column-3')[0].text |
This file contains 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
require "nokogiri" | |
require "open-uri" | |
page = Nokogiri::HTML(open("http://www.lesson1.ru/vocabulary/lexicographer/weather.html")) | |
page.search("tr")[2].each do |row| | |
original = row.css("td")[1].text | |
translated = row.css("td")[0].text | |
Card.create( original_text: original, translated_text: translated ) | |
end |
OlderNewer