増井予約システム的な何かを書いた際のメモ
カスタムバリデーションの反映
ruby on rails - rails3 doesn't load my validators in lib - Stack Overflow
ここに書いてあるように 1. config/initializers に置く もしくは 2. lib/validatorsに加えた後に、config/application.rb で
config.autoload_paths << "#{config.root}/lib/validators"
の記述をする。
その後、Rails serverを再起動。
event_calendarを使う
event_calendarに挑戦する2 - kenmituoの日記
とりあえずこれでcalendarは動くのができたような気がする
event_calendar プラグインを使って Rails でイケてるカレンダーを実装してみた - present
あとはここに書いてあるように、userの個別のカレンダーを持たせたい場合は、calendar_controller.rb で
@event_strips = Event.event_strips_for_month( @shown_month, 0, :conditions => { :user_id => current_user.id })
って書けばOK。
Modelは userの持つイベントは複数あるので has_many でひもづける
class User < ActiveRecord::Base has_many :events .... end
event.rb は belongs_to userを
class Event < ActiveRecord::Base has_event_calendar #デフォルトで書いてある belongs_to user .... end
あとはconfig/routes.rbで
match
undefined local variable or method `has_event_calendar'
こんな感じのエラーが出たのでググるとissueで出てきてた。
undefined local variable or method `has_event_calendar' · Issue #36 · elevation/event_calendar
pow使ってるので
$ powder restart
で再起動すると問題解決。反映されてなかったみたい。
undefined method `skype_id=' for #<User:0x007fae47cfad58> ってでる。
skypeのIDを登録時に入力してもらおうと思って、それをmigrateのとこに書いたつもりなんだけど、上記のエラーが出てなんでかなーとなってる ▶schema.rb が更新されてないかららしい。schema.rbはDBがどんな風に作られてるのか確認できる。