AD:
過去のサイトで、Lessを使用しているものがあったので、lessをインストール
|
$ gem install less $ less --version less 444 Copyright (C) 1984-2009 Mark Nudelman |
Twitter:
Warning: Undefined array key "Twitter" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Facebook: 0 | Google Plus:
Warning: Undefined array key "Google+" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0
AD:
I set up Rails Env with ruby 1.9.3p374 & Rails 3.2.11
I tried to use consolce and I got this massage…
Error
|
$ rails c /home/vagrant/.rbenv/versions/1.9.3-p374/lib/ruby/1.9.1/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError) from /home/vagrant/.rbenv/versions/1.9.3-p374/lib/ruby/1.9.1/irb/completion.rb:9:in `<top>' from /home/vagrant/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:3:in `require' from /home/vagrant/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:3:in `<top>' from /home/vagrant/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:38:in `require' from /home/vagrant/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:38:in `<top>' from script/rails:6:in `require' from script/rails:6:in `<main>' </main></top></top></top> |
Add re-readline
|
$ vi Gemfile gem 'rb-readline' $ bundle install |
Done
Twitter:
Warning: Undefined array key "Twitter" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Facebook: 0 | Google Plus:
Warning: Undefined array key "Google+" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Hatena: 0 | Pocket: 1 | Total: 1 | Feedly: 0
AD:
設定方法
|
$ vi config/application.rb module YourAppName class Application <h3>環境ごとに変更したい場合</h3> <pre> vi config/environments/development.rb config.site_name = "サイト名" config.site_url = "localhost:3000" |
参照方法
|
<h1></h1> @url = YourAppName::Application.config.site_url |
Done
Twitter:
Warning: Undefined array key "Twitter" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Facebook: 0 | Google Plus:
Warning: Undefined array key "Google+" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0
AD:
I want to setup contry code for my Rails app so I searched by google there are some Gem but I just want to make Tables & Model.
I used data from here
Make migratiton file
|
$ rails g model country name:string alpha_2:string alpha_3:string invoke active_record create db/migrate/20130206044924_create_countries.rb create app/models/country.rb invoke rspec create spec/models/country_spec.rb |
Add SQL from here
|
$ vi db/migrate/20130206044924_create_countries.rb #add data from http://stefangabos.ro/other-projects/list-of-world-countries-with-national-flags/ execute " INSERT INTO `countries` (`name`, `alpha_2`, `alpha_3`) VALUES ('Afghanistan', 'af', 'afg'), ('Aland Islands', 'ax', 'ala'), ('Albania', 'al', 'alb'), more... ('Zimbabwe', 'zw', 'zwe')" |
and then
Done.
Twitter:
Warning: Undefined array key "Twitter" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Facebook: 0 | Google Plus:
Warning: Undefined array key "Google+" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0
AD:
Set up ruby first
Before install Vagrant needs set up ruby. I use rbenv for setting Ruby environment
|
$ sudo apt-get update $ sudo apt-get install build-essential zlib1g-dev curl git-core sqlite3 libsqlite3-dev $ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile $ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile $ source .bash_profile $ git clone git://github.com/sstephenson/ruby-build.git $ cd ~/ruby-build/gr $ sudo ./install.sh $ rbenv install 1.9.3-p374 $ rbenv global 1.9.3-p374 $ gem install bundler $ rbenv rehash $ ruby -v ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-linux] |
Install Vagrant
|
$ apt-get install virtualbox-ose $ apt-get install rubygems $ gem install vagrant $ vagrant box add ubuntu12.10.64 https://s3-sa-east-1.amazonaws.com/willian-boxes/Ubuntu-Server-12.10-amd64-Minimal.box $ vagrant up ubuntu12.10.64 |
Twitter:
Warning: Undefined array key "Twitter" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Facebook: 0 | Google Plus:
Warning: Undefined array key "Google+" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Hatena: 1 | Pocket: 0 | Total: 1 | Feedly: 0
AD:
環境
Rubyは、rbenvで入れました。
|
$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=12.04 DISTRIB_CODENAME=precise DISTRIB_DESCRIPTION="Ubuntu 12.04.1 LTS" $ ruby -v ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] $ rails -v Rails 3.2.8 |
問題
新しくRailsからプロジェクトを作って、それをなにもGemfile変更なしにrails serverを起動したら下記のエラーが出て
|
$ rails new hoge $ cd hoge $ rails sever /gems/1.9.1/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable) |
対策
調べたところ、CoffeeScriptが入っているのでJavsacriptエンジンが必要らしいので、Gemfileに書きを追加して、解決
|
$ vi Gemfile gem 'execjs' gem 'therubyracer' $ bundle install |
Twitter:
Warning: Undefined array key "Twitter" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Facebook: 0 | Google Plus:
Warning: Undefined array key "Google+" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Hatena: 1 | Pocket: 0 | Total: 1 | Feedly: 0
AD:
最近、WordpressのRoots Themeを触っているのですが、その中でlessが使われていたのでそのメモ
|
$ sudo gem install less Successfully installed libv8-3.3.10.4-x86-linux Successfully installed therubyracer-0.9.9 Successfully installed commonjs-0.2.0 Successfully installed less-2.0.9 |
lesscの場所を確認
|
$ locate lessc /var/lib/gems/1.8/bin/lessc /var/lib/gems/1.8/gems/less-2.0.9/bin/lessc /var/lib/gems/1.8/gems/less-2.0.9/lib/less/js/bin/lessc |
コマンドを入力させやすくしておく
|
$ sudo ln -s /var/lib/gems/1.8/bin/lessc /usr/bin/ |
: Could not find RubyGem less と出てエラー
|
$ lessc hoge.less > hoge.css /usr/lib/ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem less (>= 0) (Gem::LoadError) from /usr/lib/ruby/1.8/rubygems.rb:214:in `activate' from /usr/lib/ruby/1.8/rubygems.rb:1082:in `gem' from /usr/bin/lessc:18 |
調べてみると、sudoでインストールしたので、lesscのコマンドもsudoで実行しないといけないらしい。。。
|
$ sudo lessc hoge.less > hoge.css |
既に、Rubyの開発環境はrvmで導入済みの状態です。
せっかくなので、Roots Themeのlessでのcssを書き出しもメモしておきます。
|
$ cd ./wp-content/themes/roots/css/less 全体 $ sudo lessc bootstrap.less > bootstrap.css レイアウト系 $ sudo lessc responsive.less > bootstrap-responsive.css |
ちなみに、上のRoots Themeは、標準では、css/の中にあるcssを読み込むんですが、下記のやり方だとlessの中に書き出されます。
|
$ sudo lessc ./less/bootstrap.less > bootstrap.css $ sudo lessc bootstrap.less > ../css/bootstrap.css |
上記のコマンドを試したけどダメだったので、./inc/roots-actions.phpを書き換えました。
Twitter:
Warning: Undefined array key "Twitter" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Facebook: 0 | Google Plus:
Warning: Undefined array key "Google+" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Hatena: 1 | Pocket: 0 | Total: 1 | Feedly: 0
AD:
passengerとapacheでRailsのテスト環境を作成して最後に下記のエラー
[php]No route matches “/rails/info/properties[/php]
対処法
railsの環境設定をapacheのconfに書き込んでやるとあっさり解決できました。
[php]RailsEnv development[/php]
Twitter:
Warning: Undefined array key "Twitter" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Facebook: 0 | Google Plus:
Warning: Undefined array key "Google+" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0
AD:
Ruby1.9、Rails3.0.7、gem1.6.2の環境下で、deviseをbundleのinstallしようとしてなかなかうまく行かなかったのですが、
最後は単純に解決したので同じミスをおかさないようにメモしておきます。
エラー内容
[ruby]
$ vi Gemfile
gem ‘devise’, ‘1.1.5’
$ bundle install
/Users/hoge/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb:72:in `parse’: Illformed requirement [“1,1,5”] (ArgumentError)
[/ruby]
解決方法
上記のようなエラーがでて、いろいろ試してみた結果、
[ruby]
$ vi Gemfile
gem ‘devise’ ←よけいなバージョンを消したら解決
[/ruby]
Twitter:
Warning: Undefined array key "Twitter" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Facebook: 0 | Google Plus:
Warning: Undefined array key "Google+" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0
AD:
最近MacでRailsの環境を行っているのですが、Rails3にアップデート( たしかMacPortでアップデートしたような)
して、Mysqlで開発を行おうとしたらエラーがでたので、そのメモを書いておきます。
下記のようなコマンドでプロジェクト?を生成して、さっそく走らしてみる下記のエラー
[bash]$ rails new hoge -d mysql
$ cd /hoge/
$ rails s
dyld: lazy symbol binding failed: Symbol not found: _mysql_get_client_info
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/ext/mysql2/mysql2.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_get_client_info
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/ext/mysql2/mysql2.bundle
Expected in: flat namespace
[/bash]
検索してみていろいろ試してみるが、どれもうまく行かず、最終的に下記のページの内容で解決
http://stackoverflow.com/questions/5894102/bundle-command-the-wrong-mysql2-gem-always-0-3-2
gemのmysqlのライブラリの上げて解決
[bash]
$ sudo gem uninstall mysql2 -i /Library/Ruby/Gems/1.8
$ gem ‘mysql2′,’0.2.7’
$ bundle install
[/bash]
Twitter:
Warning: Undefined array key "Twitter" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Facebook: 0 | Google Plus:
Warning: Undefined array key "Google+" in /home/sazaeau/mizoshiri.com/public_html/blog.mizoshiri.com/wp-content/plugins/sns-count-cache/sns-count-cache.php on line 2897
0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0