Skip to content

Instantly share code, notes, and snippets.

View kyamaguchi's full-sized avatar

kyamaguchi kyamaguchi

View GitHub Profile
@visnup
visnup / posts_controller.rb
Created February 14, 2010 02:00
a scaffold using respond_with
class PostsController < ApplicationController
respond_to :html, :xml, :json
# GET /posts
# GET /posts.xml
def index
@posts = Post.paginate :page => params[:page]
respond_with @posts do |format|
format.atom
end
@oukayuka
oukayuka / inputmode.rb
Created July 23, 2009 09:03
Setting default input mode to text form for mobile client.
module ActionView
module Helpers
module FormHelper
alias :text_field_without_inputmode :text_field
# ==== Options
# * <tt>:inputmode</tt> - 入力モード。Jpmobile::InputMode::HIRAGANA-全角ひらがな、Jpmobile::InputMode::HANKAKUKANA-半角カナ、Jpmobile::InputMode::ALPHABET-半角英字、Jpmobile::InputMode::NUMERIC-半角数字
# ==== Examples
# text_field_tag(:user, :name, :size => 20, :inputmode => Jpmobile::InputMode::HIRAGANA)
# # => <input id="name" name="name" type="text" size="20" istyle="1" style="-wap-input-format:&quot;&lt;ja:h&gt;&quot;">
# Para salvar a altura e largura das imagens enviadas pelo plugin paperclip, utilize o callback abaixo
#
# class Document < ActiveRecord::Base
#
# has_attached_file :document, :styles => { :medium => "300x300>" }
#
# before_save :save_dimensions
#
# def save_dimensions
# if document.image?