タグ: RubyOnRails
[RubyOnRails]Deviseを日本語化
デフォルトロケールの設定
config/application.rb
config.i18n.default_locale = :ja
rails再起動
rails s
ロケールファイルの設置
config/locales/devise.ja.yml
[RubyOnRails]Railsを日本語化
デフォルトロケールの設定
config/application.rb
config.i18n.default_locale = :ja
rails再起動
rails s
ロケールファイルの設置
config/locales/ja.yml
https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/ja.yml
[RubyOnRails]ページネーション-kaminari導入手順
https://github.com/kaminari/kaminari
Gemfileの設定
Gemfile
gem 'kaminari'
bundle install
コントローラーの設定
def index
@posts = Post.all.order(created_at: :desc)
@posts = Post.page(params[:page]).per(10)
end
ビューの設定
<% @posts.each do |post| %>
<div class="panel panel-success">
<div class="panel-body">
<%= link_to(post.content,"/posts/#{post.id}") %>
</div>
<div class="panel-footer">content_description</div>
</div>
<% end %>
<%= paginate @posts %>
[RubyOnRails]MVCを理解しよう-掲示板サービス作成手順
[RubyOnRails]検索機能の定番-Ransak導入手順
aabva
[RubyOnRails]本番サーバー構築手順(GitHub->Heroku編)
Railsの設定
Gemfileの設定
#sqlite3 # <-コメントアウトする group :development, :test do gem 'sqlite3' # <-追加する end group :production do gem 'pg' # <-追加する end
config/database.ymlの設定
# 追加する production: <<: *default adapter: postgresql encoding: unicode pool: 5
config/environments/production.rbの設定
# false → trueに変更 config.assets.compile = true
Git
git init git add -A git commit -m "(コメント)"
Heroku
heroku login heroku create (サービス名)
デプロイ
git push heroku master heroku run rails db:migrate
[RubyOnRails]Ruby基本文法まとめ
[RubyOnRails]ローカル開発環境構築手順(Windows10編)
ccc
[RubyOnRails]ローカル開発環境構築手順(Mac編)
bbb