gem 'moji'
validates_format_of :body, :with => Moji.regexp(Moji::ZEN_ALNUM | Moji::ZEN_KANA | Moji::ZEN_KANJI)
gem 'moji'
validates_format_of :body, :with => Moji.regexp(Moji::ZEN_ALNUM | Moji::ZEN_KANA | Moji::ZEN_KANJI)
begin
require 'pry'
module Rails
class Console
class IRB
def self.start
Pry.start
end
end
end
end
rescue LoadError => e
puts e
end
# also need to add pry to Gemfile console do require "pry" config.console = Pry end
config.gem 'rack-rewrite'
require 'rack/rewrite'
config.middleware.insert_before(Rack::Lock, Rack::Rewrite) do
if ENV['RACK_ENV'] == 'production'
# use Rack::Rewrite do
r301 %r{.*}, 'http://hoge.com$&', :if => Proc.new {|rack_env|
rack_env['SERVER_NAME'] != 'hoge.com'
}
# end
end
end
config/application.rbに上記のような感じで書くとRailsのRackでリダイレクト設定ができます。Herokuを使っていると便利。
<%= render :partial => ‘layouts/ga’ if RAILS_ENV == ‘production’ %>こんな感じでレイアウトに記入。パーシャルはapp/views/llayouts/_ga.html.erbみたいな感じでOK。
75.101.163.44
75.101.145.87
174.129.212.2
https://devcenter.heroku.com/articles/custom-domains#dns_setup
gem 'rvm-capistrano'
set :rvm_ruby_string, 'ree@rails3' # Or: #set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"") # Read from local system require "rvm/capistrano" # Load RVM's capistrano plugin.
bundle config build.pg --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config
rvm get 1.10.3
rvm env . -- --env > .powenv
gem 'oauth' gem 'facebook_oauth' gem 'oauth2', '0.4.1'
class UsersController < ApplicationController
CALLBACK_URL = "http://localhost:3000/users/callback"
CONSUMER_KEY = "アプリID"
CONSUMER_SECRET = "アプリの秘訣"
def index
end
def oauth
client = FacebookOAuth::Client.new(
:application_id => CONSUMER_KEY,
:application_secret => CONSUMER_SECRET,
:callback => CALLBACK_URL
)
redirect_to client.authorize_url
end
def callback
@client = FacebookOAuth::Client.new(
:application_id => CONSUMER_KEY,
:application_secret => CONSUMER_SECRET,
:callback => CALLBACK_URL
)
@client.authorize(:code => params[:code])
end
end
app/views/users/index.html.erb
<%= link_to 'OAuth認証', '/users/oauth' %>app/views/users/callback.html.erb
<%= @client.me.info %>
@@pagination_options = {
:class => 'pagination',
:prev_label => '« Previous',#前ページリンクの文言
:next_label => 'Next »',#次ページリンクの文言
:inner_window => 4,#現在ページと「...」の間のリンク数
:outer_window => 1,#「...」とnext_labelの間のリンク数
:separator => ' ', # リンク間の区切り文字
:param_name => :page, #ページ数のパラメーター名
:params => nil, #遷移先URLに付加するパラメーター
:renderer => 'WillPaginate::LinkRenderer',
:page_links => true,
:container => true
}
変更したい所でオーバーライドしてあげればOK
% script/generate twitter_auth
gem 'crummy'パンくずリスト表示したい場所に下記の通り記載
<%= render_crumbs %>あとはアクションで項目を追加していけます。
class ApplicationController < ActionController::Base add_crumb 'HOME', '/' end
gem "ruby-debug19"あとはrails s --debugでサーバーを起動するとdebuggerと記載されたところで止まります。その後は下記のコマンドにて詳細を確認できます。
<%= content_for?(:title) ? yield(:title) : "デフォルトタイトル"%>あとはタイトルを変えたいビューで書き換えてあげる
<% content_for :title do %> 書き換えたいタイトル <% end %>
git ls-files -u
<%= flash[:notice] if flash[:notice] %>コントローラーで文言を入れる
flash[:notice] = "hogehoge"