2008-02-01から1ヶ月間の記事一覧
layout lambda { |controller| controller.request.mobile? ? 'mobile/forms' : 'forms' } Young risk taker.: [Rails] Mobile on Railsの変更
viewで <%= link_to :hoge, {:action => :fuga} %>なときは、 <a href="/xxx/fuga?_sid=098731246hdfa9s8hdf">hoge</a> みたいになるけど名前付きルートで <%= link_to :hoge, fuga_path(@fuga) %>とかのように、名前指定で引数を渡したときだけだと、 def link_to(name, options = {}, html_options = nil) ur…
has_many :hoge_groups, :order => :positionじゃなくて has_many :groups, :class_name => "HogeGroup", :order => :positionでも、おk 命名規約に従うべきかもだけど、xxxxx_xxxxxx_xxxxx_groupsとかウザ過ぎる。
便利に慣らされて脳みそ腐ってた tags = document.getElementsByTagName("input"); for (var i = 0; i < tags.length ; i++) { if(tags[i].type == "checkbox") { tags[i].checked = true; } } prototype.jsありだと $$('input.question_check').each(functi…
grep -r -l 'hogehoge' ./*
参考 http://d.hatena.ne.jp/j-souma/20070612
あとづけなvalidatess Hoge.validates_inclusion_of :detail, :in => %w{ 2 3 } fuga= Hoge.new(:foo=> params[:hoge][:foo] ) detail.valid? params[:hoge][:foo]は1だとfalse params[:hoge][:foo]は2だとtrue これ駄目だわ あとのが全部バリデーション効い…
report = '' CSV::Writer.generate(report, ',') do |csv| csv << ["ログイン名 ", "パスワード"] User.find_all.each do |model| csv << [model.login, model.password] end end send_data(NKF.nkf('-U -s -Lw', report), :type => 'text/csv; charset=shif…
参考 Rails開発日記 AUTH_TYPE : request.auth_type CONTENT_LENGTH : request.content_length CONTENT_TYPE : request.content_type GATEWAY_INTERFACE : request.gateway_interface PATH_INFO : request.path_info PATH_TRANSLATED : request.path_transla…
script/plugin install svn://errtheblog.com/svn/plugins/will_paginate 参考 m(__)m http://brass.to/blog/will_paginate.html AutoPagerizeなwill_paginateにしておく - ザリガニが見ていた...。 will_paginate - happy lie, happy life will_paginate の…
gemディレクトリ/rails-2.0.2/lib/rails_generator/generators/components
フツーに文字にリンクさせる方法をしらなかった Google グーグル様 ここは絵日記だということをしらなかった おえかきおもれー これは、ハテナハイクについてる機能?ハテナハイクやったことないけど。 なんだ、久しぶりにWEBにふつーに日記でも書いてみたく…
参考 http://d.hatena.ne.jp/n314/20070116/1168936382 http://weblog.metareal.org/2007/09/02/prototype-1-6-0-event-overhaul-release/ http://www.akatsukinishisu.net/itazuragaki/js/bindaseventlistener.html
<%=h @hoge %> だと、けっこう問答無用でエスケープされる。 でも、ある程度のHTMLは入力許したいとき、タグと属性をホワイトリストで指定できた。 <%= sanitize %(<table><tr><td><font id="hoge" style="color:red;">ほげ</font></td></tr></table>), :tags => %w(font), :attributes => %w(class style) %> で表示されるのは <font style="color:red;">ほげ</font> だけ…
プラグイン作ってその中で module ActionView module Helpers module DateHelper #中略 def select_html(type, html_options, options) case type when "year" then html_class = %(class = "#{options[:yclass] || "date_select"}") when "month" then html…
<% hoge = "hogehoge" %> <%= javascript_tag(%( window.onload=function default() { alert("#{hoge}"); } )) %>
ruby script/plugin install acts_as_list
class Hoge< ActiveRecord::Base has_many :hoges_fugas_assigns has_many :fugas, :through => :hoges_fugas_assigns, :source => :wawawa_fuga #以下略 class WawawaFuga< ActiveRecord::Base has_many :hoges_fugas_assigns has_many :hoges, :through =>…
/admin/hoge/1/fuga/hoo/wawawaとかしたいとき map.namespace :hoge do |hoge| hoge.resources :fuga do |fuga| fuga.resources :hoo, :member=> [:wawawa] end end 参考 http://d.hatena.ne.jp/zariganitosh/20080203/1202091772
rails2でscaffoldすると、migrateも作られるようになったのはわかった。 で、usersがある状態で/admin/usersみたいな会員管理コントローラを作りたいとき。#いや、管理ページはRestfullにする必要ないかもしれないけど。。/mypage/xxxとかありうると思うから…
acts_as_authenticated インスコ→じぇねる→migrate $ ./script/plugin install acts_as_authenticated $ ./script/generate authenticated user account $ rake db:migrateで、おk role_requirement インスコ→じぇねる→migrate $ script/plugin install htt…
1. /etc/mail/sendmail.mc 中、「DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')」をコメントアウト。http://q.hatena.ne.jp/1179711865 の部分だけまねしたら出て行った。
消えちゃったよ。。 はてなダイアリー素人なので書いたのをなんか間違って消してしまった。。orz 後半だけクリップボードに残ってた。orz なので、書き直した前半は適当。 acts_as_authenticatedをインストール $ ruby script/plugin discover $ ruby script…
昨日macに入れたmysqlにユーザーを作った。 rootと同じ権限 mysql> GRANT ALL PRIVILEGES ON *.* TO user@"%" -> IDENTIFIED BY 'パスワード' WITH GRANT OPTION; mysql> GRANT ALL PRIVILEGES ON *.* TO user@localhost -> IDENTIFIED BY 'パスワード' WITH…
一個前の続き。 とりあえず、コントローラーをexampleみながら 直した。とりあえず、これでやってみる。 require "pathname" require "openid" require 'openid/extensions/sreg' require 'openid/extensions/pape' require 'openid/store/filesystem' class…
gem入れる $ gem install ruby-openid $ gem install openid_login_generator $ gem install ruby-yadis $ gem list --local (略) openid_login_generator (0.1) rails (2.0.2) rake (0.8.1) ruby-openid (2.0.3) ruby-yadis (0.3.4) 新しいRailsプロジェク…
ダウンロード http://svn.macosforge.org/repository/macports/downloads/ のdmgをダウンロード インストール 普通にクリックしていく PATHを通す homeディレクトリの.bashrcじゃなくて.bash_profileに export PATH=/opt/local/bin:/opt/local/sbin/:$PATH e…