差分表示

  • 最後の更新で追加された行はこのように表示します。
  • 最後の更新で削除された行はこのように表示します。

#contents

*概要

Javaから見たRuby on Rails
http://www.atmarkit.co.jp/fjava/special/javvsaror/ror01.html

O/Rマッピング
http://www.thinkit.co.jp/free/article/0608/12/1/

*情報源

http://techno.hippy.jp/rorwiki/?HowtosDevelopment
http://api.rubyonrails.org/
http://d.hatena.ne.jp/yoshitetsu/searchdiary?word=%2a%5brails%5d
*Tips

PostgreSQLの利用
http://d.hatena.ne.jp/mrkn/20070321/rails_usage

LiveSearchを日本語でも通るようにする
http://blueruby.mydns.jp/articles/tag/rails

has_many :through
http://www.matthewman.net/articles/2006/01/06/rails-activerecord-goes-through

[[Ruby on Rails - submit_tag で付加される commit, utf8 パラメータ! - mk-mode BLOG>http://www.mk-mode.com/octopress/2014/06/11/rails-commit-utf8-param-of-submit-tag]]
*Ajax

http://www.thinkit.co.jp/free/article/0605/2/5/
http://wiki.fdiary.net/rails/?AjaxOnRails

*cygwinにインスコ

http://leoclock.blogspot.com/2005/12/ruby-on-rails_17.html

それと
 $ gem install postgres-pr
*ActiveRecord単体で使う

http://fg-180.katamayu.net/archives/2007/03/11/234250
http://jp.rubyist.net/magazine/?0006-RubyOnRails

*bootstrapを使う
こちらを参考に
https://github.com/nicklegr/microblog-test/commit/47fda3b74145c2ed99b660524b6c141805317b9a

vender/assets 以下に入れる。

アイコンを使うには、config/application.rbに
 config.assets.paths << Rails.root.join("vendor", "assets", "images")

bootstrap.cssの中を
 url("../assets/glyphicons-halflings.png");

*twitter-bootstrap-railsを使う
インストール
 gem 'twitter-bootstrap-rails'

scaffoldで生成されたページを簡単にかっこよくできる
 rails g bootstrap:themed Users
modelを複数形で指定することに注意

標準のscaffoldとcssがかち合うので、下記を削除
 /app/assets/stylesheets/scaffolds.css.scss
*jquery sortable
並べ替える要素のIDを、foo_1, foo_5, foo_2のようにアンダースコアを入れたネーミングにする必要がある
http://stackoverflow.com/questions/965083/jquery-sortable-list-wont-serialize-why

twitter-bootstrap-railsでrails g bootstrap:themedすると、IDが未指定なので注意

Modelに、
 default_scope order('position asc') 
を追加すると、Model.allするだけで並べ替えたとおりの順番になる

sortable + disableSelection + jeditableを組み合わせると、
編集中にマウスクリックでカーソルが移動できなくなる不具合が起きる。
disableSelectionを外すと解決する

*kaminari
TwitterやFacebookみたいな無限スクロール
https://github.com/amatsuda/kaminari/wiki/How-To:-Create-Infinite-Scrolling-with-jQuery

このままだとデータの末尾まで来てもロードを繰り返すので、
204 No Contentを返してあげて、$.ajax時に検出して動作を停止するといい

*production環境での注意
**ルートURLの変化
例えば
 http://localhost:3000/ -> http://mydomain.com/hoge-app/
のように変えた場合、絶対パスでURLを書いている部分が通らなくなる。
viewでは、 url_for, hoge_path のようなヘルパーを使うといい。

JS内のAjax呼び出しのURLも注意。
hoge.js.erbとして、プリプロセスをかける仕組みがあるらしい。
そこで url_for すればいいと思う
**Asset Pipeline
production環境でAsset Pipelineが有効になるとjs, cssが1ファイルにまとめられるので、
 %script{ type: "text/javascript", src: "/assets/validate_report.js" }
のように自前でロードしている箇所が動かなくなる。
自前でロードせず、Asset Pipelineのルールに従う。