Skip to content

Instantly share code, notes, and snippets.

class IndexController < ApplicationController
def index
if current_user
if !current_user.cards.empty?
@random_card = current_user.due_cards.first
elsif current_user.decks.empty?
redirect_to new_deck_path, alert: 'Создайте колоду и добавьте карточки'
else
redirect_to decks_path, alert: 'Добавьте карточки в колоду'
class IndexController < ApplicationController
def index
if current_user
if !current_user.cards.empty?
@random_card = current_user.due_cards.first
card = current_user.cards.find(params[:card_id])
@result = card.check_translation(params[:search])
elsif current_user.decks.empty?
redirect_to new_deck_path, alert: 'Создайте колоду и добавьте карточки'
D, [2014-09-07T22:56:09.572244 #37947] DEBUG -- : ActiveRecord::SchemaMigration Load (0.7ms) SELECT "schema_migrations".* FROM "schema_migrations"
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
D, [2014-09-07T22:56:09.604782 #37947] DEBUG -- :  (0.2ms) BEGIN
D, [2014-09-07T22:56:09.611129 #37947] DEBUG -- :  (0.2ms) SAVEPOINT active_record_1
D, [2014-09-07T22:56:09.611420 #37947] DEBUG -- :  (0.1ms) RELEASE SAVEPOINT active_record_1
D, [2014-09-07T22:56:09.611719 #37947] DEBUG -- :  (0.1ms) SAVEPOINT active_record_1
D, [2014-09-07T22:56:09.661679 #37947] DEBUG -- : User Exists (1.4ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'windsochi@gmail.com' LIMIT 1
D, [2014-09-07T22:56:09.831547 #37947] DEBUG -- : SQL (7.8ms) INSERT INTO "users" ("created_at", "crypted_password", "email", "salt", "updated_at") VALUES ($1, $2,
class CardsController < ApplicationController
before_action :find_card, only: [:show, :edit, :update, :destroy]
def index
@cards = current_user.cards
end
def new
@card = Card.new
end
macbook15:flashcard_static litos$ rails s
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/Users/litos/.rvm/gems/ruby-2.1.2/ruby/2.1.0/gems/fog-core-1.24.0/lib/fog/core/service.rb:237:in `validate_options': Missing required arguments: aws_access_key_id, aws_secret_access_key (ArgumentError)
from /Users/litos/.rvm/gems/ruby-2.1.2/ruby/2.1.0/gems/fog-core-1.24.0/lib/fog/core/service.rb:261:in `handle_settings'
from /Users/litos/.rvm/gems/ruby-2.1.2/ruby/2.1.0/gems/fog-core-1.24.0/lib/fog/core/service.rb:98:in `new'
from /Users/litos/.rvm/gems/ruby-2.1.2/ruby/2.1.0/gems/fog-core-1.24.0/lib/fog/storage.rb:26:in `new'
macbook15:flashcard_static litos$ bundle install
Fetching gem metadata from https://rubygems.org/........
Fetching additional metadata from https://rubygems.org/..
Using rake 10.3.2
Using i18n 0.6.11
Using minitest 4.7.5
Using multi_json 1.10.1
Using thread_safe 0.3.4
Using tzinfo 0.3.41
Using activesupport 4.0.2
macbook15:flashcard_static litos$ gem install nokogiri -v '1.6.3.1'
ERROR: Loading command: install (LoadError)
dlopen(/usr/local/Cellar/ruby/2.1.2_2/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle, 9): Symbol not found: _SSLv2_client_method
Referenced from: /usr/local/Cellar/ruby/2.1.2_2/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle
Expected in: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
in /usr/local/Cellar/ruby/2.1.2_2/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle - /usr/local/Cellar/ruby/2.1.2_2/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
macbook15:flashcard_static litos$ bundle install
Fetching source index from https://rubygems.org/
Using rake 10.3.2
Using i18n 0.6.11
Using minitest 4.7.5
Using multi_json 1.10.1
Using thread_safe 0.3.4
Using tzinfo 0.3.41
Using activesupport 4.0.2
Using builder 3.1.4
Running `rake db:migrate` attached to terminal... up, run.5112
Migrating to CreateCards (20140722155038)
== CreateCards: migrating ====================================================
-- create_table(:cards)
-> 0.0335s
-- add_index(:cards, :user_id)
PG::UndefinedColumn: ERROR: column "user_id" does not exist
: CREATE INDEX "index_cards_on_user_id" ON "cards" ("user_id")
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
class Notebook
@@notebooks_count = 0
attr_accessor :notebook
def self.count
@@notebooks_count
end
def add_note(note)
notebook.push(note)