среда, 24 декабря 2014 г.

GIT. Commits. Branches

git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/thedobriy/my_cat_1.git
git push -u origin master
heroku create
git push heroku master
heroku run rake db:migrate

git co -b static-pages  - создание ветки
rails g controller StaticPages --no-test-framework
git add .
git commit -m "Finish static pages"
git co master
git merge static-pages
git push
git push heroku
heroku run rake db:migrate

понедельник, 22 декабря 2014 г.

Installing VIM

Source: http://smileart.in.ua/vim-101

$ vim --version | grep ruby
$ apt-cache search vim | grep vim-
$ sudo apt-get install vim-rails
$ sudo apt-get install exuberant-ctags
wget --no-check-certificate https://github.com/joshfng/railsready/raw/master/railsready.sh
&& bash railsready.sh
Дальше все делаем по инструкции  от самого akitaonrails. Я буду следовать только ее Linux части, ведь ставлю все это, как уже говорил, под управлением Ubuntu. Практически то же актуально и для MacOS X. Владельцы других ОС могут сами подсмотреть в README.textile, что и как им делать.

Клонируем репозиторий в ту самую папку vim:

$ git clone git://github.com/akitaonrails/vimfiles.git ~/.vim
Далее переходим в нее и запускаем инициализацию/обновление модулей:

$ git submodule update --init
Теперь создаем файлик .vimrc, в который прописываем где у нас лежит .vimrc с настройками akita

$ echo "source ~/.vim/vimrc" > ~/.vimrc
Если вы планируете использовать gvim (графический вариант vim с меню и прочими понтами), то вам стоит создать и .gvimrc

echo "source ~/.vim/gvimrc" > ~/.gvimrc

четверг, 18 декабря 2014 г.

Ruby on Rails, мультиязычность

Добавить в Gemfile строчку
gem 'i18n'
(выполнить bundle install)

в config/application.rb раскомментировать строки и выбрать нужный язык:
config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :ru

в config/locales/en.yml прописать соответствия ключ-значение для нужных языков, например:
en:
  admin_title: "Admin Panel"
  user_created: "succesfully created."
  .....
ru:
  admin_title: "Панель администрирования"
  .....

использовать можно с помощью хелпера t(:key) в контроллерах:
flash[:notice] = "#{@user.login} #{t :user_created}"
и view (haml):
%title= t :admin_title

Guide

VIM keys

o  to open a line BELOW the cursor and start Insert mode.
O  to open a line ABOVE the cursor.

a  to insert text AFTER the cursor.
A  to insert text after the end of the line.

e  command moves to the end of a word.

y  operator yanks (copies) text,  p  puts (pastes) it.

R  enters Replace mode until  <ESC>  is pressed.

Typing ":set xxx" sets the option "xxx".  Some options are:
  'ic' 'ignorecase' ignore upper/lower case when searching
'is' 'incsearch' show partial matches for a search phrase
'hls' 'hlsearch' highlight all matching phrases

пятница, 12 декабря 2014 г.