flash[:notice] = t('request.confirm_success') page.replace_html :notice, flash[:notice] flash.discard
2010/02/25
rjs でflash を書き換える
2010/02/18
calendar_date_select plugin doesn't accept minute intervals
calendar_date_select で、分のインターバルを00、30等に設定していても、最初に設定されるデフォルト分数が現在時刻の分の値をとってきてしまう問題の解消法
if (isNaN(this.date)) this.date = new Date();を、以下に変更
if (isNaN(this.date)) { this.date = new Date(); this.date.setMinutes(Math.ceil(this.date.getMinutes() / this.options.get("minute_interval")) * this.options.get("minute_interval")); }
2010/02/17
Tips on views
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title><%= h(yield(:title) || "Untitled") %></title> <%= stylesheet_link_tag "/jqtouch/jqtouch.min.css", "/jqtouch/themes/apple/theme.min.css" %> <%= javascript_include_tag "/jqtouch/jquery.1.3.2.min.js", "/jqtouch/jqtouch.min.js", "mobile" %> <%= yield(:head) %> </head> <body> <div class="current"> <%- if show_title? -%> <div class="toolbar"> <%= link_to "Back", nil, :class => "back" unless current_page? root_path %> <h1><%=h yield(:title) %></h1> <%= link_to "Full Site", root_url(:mobile => 0), :class => "button", :rel => "external" %> <%= yield(:toolbar) %> </div> <%- end -%> <% unless flash.empty? %> <div class="info"> <%- flash.each do |name, msg| -%> <%= content_tag :div, msg, :id => "flash_#{name}" %> <%- end -%> </div> <% end %> <%= yield %> </div> </body> </html>
<% content_for :head do %> <%= stylesheet_link_tag 'projects' %> <% end %>http://railscasts.com/episodes/199-mobile-devices
2010/02/16
2010/02/09
localized_country_select で国名選択
ruby script/plugin install git://github.com/karmi/localized_country_select.git
rake import:country_select 'ja'
<%= localized_country_select(:user, :country, [], :include_blank => 'Please choose...') %> <%= I18n.t @user.country, :scope => 'countries' %>
2010/02/04
has_many association でソート順を指定
モデルのなかで
has_many :children, :order => "sort ASC"その他、ソートに便利な・・・
for child in @parent.children.reverse # ... end
2010/02/03
2010/02/01
activerecord エラーを追加する方法
def before_update if !check_something? self.errors.add(:name, "There's an error with the name") self.errors.add_to_base("There's an error with the name") return false end return true end
登録:
投稿 (Atom)