履歴: ソフトウェア/rails/PaperTrail+ActiveScaffold
各行は、その日時に書かれた内容です。追加・削除は、1 つ前の版との行数の差です (全 19 版)。「差分」は比較する版、「基準」は比べる相手の版を選びます
| 日時 | タイトル | 文字数 | 追加 | 削除 | 内容 | 差分 | 基準 |
|---|---|---|---|---|---|---|---|
| 2017/11/29 23:51:31 | ソフトウェア/rails/PaperTrail+ActiveScaffold 最新版 | 65,862 | +1 | -1 | 表示 | 差分 | — |
| 2017/11/29 23:51:31 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 65,868 | +142 | -40 | 表示 | 表示中 | 選択 |
| 2017/11/20 22:46:29 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 62,621 | +28 | -7 | 表示 | 差分 | 選択 |
| 2017/11/17 4:40:23 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 62,164 | +439 | -168 | 表示 | 差分 | 選択 |
| 2017/11/11 0:33:35 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 56,254 | +62 | -0 | 表示 | 差分 | 選択 |
| 2017/11/10 15:30:30 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 54,775 | +234 | -0 | 表示 | 差分 | 選択 |
| 2017/7/21 3:01:44 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 45,642 | +217 | -0 | 表示 | 差分 | 基準 |
| 2014/10/28 2:23:29 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 37,600 | +18 | -1 | 表示 | 差分 | 選択 |
| 2014/5/20 12:30:48 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 37,301 | +3 | -1 | 表示 | 差分 | 選択 |
| 2014/5/19 7:59:00 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 37,274 | +1 | -1 | 表示 | 差分 | 選択 |
| 2014/5/16 12:35:23 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 37,268 | +141 | -13 | 表示 | 差分 | 選択 |
| 2014/5/16 2:38:10 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 33,839 | +118 | -1 | 表示 | 差分 | 選択 |
| 2014/5/16 1:02:59 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 30,813 | +225 | -26 | 表示 | 差分 | 選択 |
| 2014/5/1 16:06:00 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 25,360 | +329 | -0 | 表示 | 差分 | 選択 |
| 2014/4/30 13:35:06 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 16,966 | +264 | -0 | 表示 | 差分 | 選択 |
| 2014/4/28 1:10:44 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 10,805 | +4 | -0 | 表示 | 差分 | 選択 |
| 2014/4/25 2:51:34 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 10,732 | +2 | -2 | 表示 | 差分 | 選択 |
| 2014/4/24 15:21:55 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 10,728 | +382 | -1 | 表示 | 差分 | 選択 |
| 2014/4/24 11:01:35 | ソフトウェア/rails/PaperTrail+ActiveScaffold | 1,131 | — | — | 表示 | — | 選択 |
基準: ソフトウェア/rails/PaperTrail+ActiveScaffold (2017/7/21 3:01:44) → 比較: ソフトウェア/rails/PaperTrail+ActiveScaffold (2017/11/29 23:51:31)
@@ -1694,6 +1694,696 @@
Gemfile を見直す必要がありそう。
+* Rails 5 でも動くようにしたい (2017-11) [#l94df97e]
+
+ruby, rails, bundler とも現時点での最新版を使ってみます。
+
+ LANG:console
+ $ cat ~/.gemrc
+ install: --no-document
+ update: --no-document
+ $ rvm --version
+ rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com>
+ $ echo "ruby-2.4.2" > .ruby-version
+ $ echo "tpsf" > .ruby-gemset
+ $ cd .
+ ruby-2.4.2 is not installed.
+ To install do: 'rvm install ruby-2.4.2'
+ $ rvm install ruby-2.4.2
+ $ cd .
+ $ gem --version
+ 2.6.14
+ $ gem install rails
+ $ rails --version
+ Rails 5.1.4
+ $ bundler --version
+ Bundler version 1.16.0
+ $ rails new tpsf
+ ...
+
+ The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for.
+ Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java.
+ To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
+ ...
+
+ Bundle complete! 16 Gemfile dependencies, 70 gems now installed.
+ Use `bundle info [gemname]` to see where a bundled gem is installed.
+ run bundle exec spring binstub --all
+ * bin/rake: spring inserted
+ * bin/rails: spring inserted
+ $ cd tpsf
+ $ git add .
+ $ git commit -m "initial commit"
+ $ jed Gemfile
+ - gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
+ + #gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
+ +
+ + gem 'paper_trail'
+ + gem 'active_scaffold', git: 'https://github.com/activescaffold/active_scaffold.git', branch: 'master', ref: 'b3a4859'
+ + gem 'paranoia'
+ + gem 'jquery-rails'
+ + gem 'jquery-ui-rails'
+ $ bundle install
+ $ rails g active_scaffold:install
+ Running via Spring preloader in process 13454
+ route concern :active_scaffold, ActiveScaffold::Routing::Basic.new(association: true)
+ route concern :active_scaffold_association, ActiveScaffold::Routing::Association.new
+ insert app/assets/javascripts/application.js
+ insert app/assets/stylesheets/application.css
+ $ rails g paper_trail:install --with-changes
+ Running via Spring preloader in process 14299
+ create db/migrate/20171110151301_create_versions.rb
+ create config/initializers/paper_trail.rb
+ $ rails db:create
+ Created database 'db/development.sqlite3'
+ Created database 'db/test.sqlite3'
+ $ rake db:migrate
+ == 20171110151301 CreateVersions: migrating ===================================
+ -- create_table(:versions)
+ -> 0.0074s
+ -- add_index(:versions, [:item_type, :item_id])
+ -> 0.0031s
+ == 20171110151301 CreateVersions: migrated (0.0112s) ==========================
+ $ git add .
+ $ git commit -m "gem tzinfo-data removed / gems jquery, jqyery-ui, paper_trail, active_scaffold and paranoia installed"
+
+active_scaffold は新しいバージョンを入れないと動かない。
+
+とりあえずインストール終了。
+
+** モデルの作成 [#t681bc7f]
+
+ LANG:console
+ $ rails g active_scaffold:resource Test name:string email:string
+ Running via Spring preloader in process 13486
+ invoke active_record
+ create db/migrate/20171110143107_create_tests.rb
+ create app/models/test.rb
+ invoke test_unit
+ create test/models/test_test.rb
+ create test/fixtures/tests.yml
+ route resources :tests, concerns: :active_scaffold
+ invoke active_scaffold:controller
+ create app/controllers/tests_controller.rb
+ create app/helpers/tests_helper.rb
+ invoke test_unit
+ create test/controllers/tests_controller_test.rb
+ create app/views/tests
+ $ rake db:migrate
+ == 20171110143107 CreateTests: migrating ======================================
+ -- create_table(:tests)
+ -> 0.0052s
+ == 20171110143107 CreateTests: migrated (0.0056s) =============================
+ $ git commit -a -m "active_scaffold を master ブランチの最新版にした"
+ $ rails s
+
+http://localhost:3000/tests
+
+へのアクセスで一覧画面が出た。
+
+&ref(tpsf-tests-list1.png,,75%);
+
+** Create New でエラーが出る [#i673c95d]
+
+[Create New] を押したら、
+
+ Uncaught SyntaxError: Unexpected token <
+ at processResponse (rails-ujs.self-817d9a8cb641f7125060cb18fefada3f35339170767c4e003105f92d4c204e39.js?body=1:246)
+ at rails-ujs.self-817d9a8cb641f7125060cb18fefada3f35339170767c4e003105f92d4c204e39.js?body=1:173
+ at XMLHttpRequest.xhr.onreadystatechange (rails-ujs.self-817d9a8cb641f7125060cb18fefada3f35339170767c4e003105f92d4c204e39.js?body=1:230)
+
+エラーが出たのは、
+
+ LANG:javascript
+ } else if (type.match(/\b(?:java|ecma)script\b/)) {
+ script = document.createElement('script');
+ script.text = response;
+ document.head.appendChild(script).parentNode.removeChild(script);
+
+appendChild の所なので、javascript を期待してたのに html が帰ってきてしまったという感じ。
+
+えー、そんなぁ。
+
+** javascript の require を直す [#be38a622]
+
+ LANG:console
+ $ jed app/assets/javascripts/application.js
+ - // require rails-ujs
+ + //# require rails-ujs
+ + //= require jquery
+ + //= require jquery_ujs
+ + //= require active_scaffold
+ $ git commit -a -m "active_scaffold が動くように application.js の require を修正"
+
+Create New が動くようになった。
+
+&ref(tpsf-tests-new1.png,,75%);
+
+* TrailedParanoidScaffold を仕込む [#bd13c5be]
+
+app/models/trailed_paranoid_scaffold.rb
+ LANG:ruby
+ # coding: utf-8
+ #
+ # Osamu Takeuchi <osamu@big.jp>
+ #
+ # 2014.05.02 初期リリース
+ # 2014.05.16 build を実装した
+ # 2017.11.29 Rails 5 用に改修 & route 定義だけで使えるようにした
+ #
+ module TrailedParanoidScaffold
+
+ #
+ # Model に include する
+ #
+ module Model
+ def self.included(base)
+ base.class_eval do
+ # 論理削除を使う
+ acts_as_paranoid
+
+ # 履歴情報を持たせる
+ if @paper_trail_ignore
+ has_paper_trail :ignore => @paper_trail_ignore
+ else
+ has_paper_trail :ignore => [:id, :created_at, :updated_at]
+ end
+
+ # http://stackoverflow.com/questions/3194290/why-cant-there-be-classes-inside-methods-in-ruby
+ base.const_set :History, Class.new(PaperTrailHistory) do
+ end
+
+ has_many :histories, -> { where "item_type = \"#{base.to_s}\"" },
+ foreign_key: 'item_id', class_name: "#{base.to_s}::History"
+ end
+ end
+ end
+
+ class PaperTrailHistory < PaperTrail::Version
+ def method_missing(action)
+ unless self.reify.attributes.keys.index(action.to_s).nil?
+ self.reify[action]
+ else
+ super
+ end
+ end
+ end
+
+ #
+ # ModelsController に include する
+ #
+ module Controller
+
+ module ClassMethods
+ def active_scaffold(model_id, &block)
+ super(model_id) do |conf|
+ conf.columns.exclude :versions
+ conf.show.columns.add :created_at, :updated_at
+ conf.create.columns.exclude :histories, :deleted_at
+ conf.update.columns.exclude :histories, :deleted_at
+ conf.list.columns.exclude :deleted_at, :created_at, :updated_at
+ conf.action_links.add 'restore', :label => 'Restore', :type => :member,
+ :confirm => 'Are you sure you want to restore the record?',
+ :method => :put, :position => :false
+ conf.actions.exclude :deleted_records
+ block.call(conf) if block
+ end
+ end
+ end
+
+ def self.included(base)
+
+ base.class_eval do
+
+ extend ClassMethods
+
+ # 削除を元に戻すアクション
+ def restore
+ do_restore
+ respond_to_action(:restore)
+ end
+
+ protected
+
+ # 削除済みのレコードも表示する
+ def beginning_of_chain
+ nested? ? super() : super().unscoped
+ end
+
+ # acts_as_paranoid で deleted_at が立てられたレコードを復帰させる
+ def do_restore
+ do_edit
+ @record.deleted_at = nil
+ update_save(no_record_param_update: true)
+ end
+
+ def restore_respond_to_js
+ update_row
+ end
+
+ def destroy_respond_to_js
+ # Update row instead of deleting
+ update_row
+ end
+
+ def update_row
+ if successful?
+ # 行を更新
+ render :action => 'update_row'
+ else
+ # エラーメッセージを表示する
+ render :action => 'destroy'
+ end
+ end
+ end
+ end
+
+ end
+
+ #
+ # ModelsHelper に include する
+ #
+ module Helper
+
+ # 削除済みのレコードに Edit および Delete のリンクを付けない
+ # 削除済みのレコードだけに Restore のリンクを付ける
+ def skip_action_link?(link, *args)
+ return false unless (args.size > 0) and args[0].respond_to?(:deleted_at)
+ return true if args[0].deleted_at and (link.action=='destroy' or link.action=='edit')
+ return true if not args[0].deleted_at and (link.action=='restore')
+ end
+
+ def self.included(base)
+ base.class_eval do
+ # ヘルパークラス名( = SomeScope::SomeModelsHelper )からモデル名を取り出す
+ model_id = base.to_s.split(/::/).last.gsub(/Helper$/,'').underscore.singularize
+
+ # histories の表示を "# 数字" にする
+ define_method("#{model_id}_histories_column") do |record, column|
+ ("# #{record.versions.size.to_s} @ #{l record.updated_at, format: :short}" +
+ ( record.versions.last.whodunnit ? "<br> by #{record.versions.last.whodunnit}" : '')).html_safe
+ end
+ end
+ end
+
+ end
+
+ #
+ # HistoriesController に include する
+ #
+ module HistoriesController
+
+ module ClassMethods
+ def active_scaffold(model_id, &block)
+ super model_id do |conf|
+
+ # 編集を不可にする
+ conf.actions.exclude :create, :update, :delete
+
+ # 履歴に日時を表示する
+ conf.columns.add :created_at
+ conf.columns[:created_at].label = "Time"
+
+ # リストに表示する内容と順番を指定
+ conf.list.columns= [:item, :event, :created_at, :object_changes]
+ conf.list.sorting= { :created_at => :desc }
+
+ # 検索をしやすくする
+ conf.actions.exclude :search
+ conf.actions.add :field_search
+ conf.field_search.columns = [:event,:created_at,:object_changes]
+
+ block.call(conf) if block
+ end
+ end
+ end
+
+ def self.included(base)
+ base.class_eval do
+ extend ClassMethods
+
+ protected
+
+ # 親クラスは削除済みのレコードも検索する
+ def nested_parent_record(crud = :read)
+ @nested_parent_record ||=
+ find_if_allowed(nested.parent_id, crud, nested.parent_model.unscoped)
+ end
+ end
+ end
+
+ end
+
+ #
+ # HistoriesHelper に include する
+ #
+ module HistoriesHelper
+
+ def self.included(base)
+ base.class_eval do
+ # ヘルパークラス名 (= SomeScope::SomeModel::HistoriesHelper) からモデル名を取り出す
+ model_id = base.to_s.gsub(/::(?=[^:]+$)|Helper$/,'').sub(/.*::/,'').underscore.singularize
+
+ # 更新履歴の表示形式
+ define_method("#{model_id}_object_changes_column") do |record, column|
+ # まるっきり美しくないけれどとりあえず
+ result = "<table>"
+ record.changeset.each do |k,v|
+ result += "<tr><td style=\"text-align:right;border:0px;width:100px;\">"+
+ "<b>#{k}</b><td style=\"border:0px;\">#{v}</tr>\n"
+ end
+ result += "</table>"
+ result.html_safe
+ end
+
+ define_method("#{model_id}_created_at_column") do |record, column|
+ ( l(record.created_at)+"<br>"+
+ (record.whodunnit ? " by " + record.whodunnit : "")
+ ).html_safe
+ end
+ end
+ end
+
+ end
+
+ #
+ # Controller, Helper を作成する関数
+ #
+ # app/controllers/admin/models_controller.rb
+ # app/helpers/admin/models_helper.rb
+ # app/controllers/admin/model/histories_controller.rb
+ # app/helpers/admin/model/histories_helper.rb
+ #
+ # といったファイルから、
+ #
+ # TrailedParanoidScaffold::build(__FILE__) do
+ # end
+ #
+ # の形で呼び出すことを想定している。
+ #
+ def self.build(file, parent = nil, &block)
+ file = File.expand_path(file).sub(/.*\/app\/(controllers|helpers)\//,'').sub(/\.rb\z/,'')
+ self.build_sub(file, parent, &block)
+ end
+
+ # admin/models_controller.rb
+ # admin/models_helper.rb
+ # admin/model/histories_controller.rb
+ # admin/model/histories_helper.rb
+ # のような文字列を渡す
+ def self.build_sub(file, parent = nil, &block)
+ unless file =~ /([^\/]+)(\/histories)?_(controller|helper)\z/
+ throw "unexpected file name #{file}"
+ end
+
+ # 必要な情報をファイル名から取り出す
+ controller_or_helper = $3 # "controller" or "helper"
+ histories = $2 # "histories" or nil
+ model = $1 # "model"
+ model = model.singularize unless histories
+
+ *path, name = file.split(File::Separator).map{|s| s.classify}
+
+ # Admin::ModelsController
+ # Admin::ModelsHelper
+ # Admin::Model::HistoriesController
+ # Admin::Model::HistoriesHelper
+ # といった定数に結びつけたい
+ # このとき Controller は AdminController を継承する
+
+ # そのために Admin や AdminController のようなモジュールや
+ # クラスを定義する
+
+ # c = controller, n = namespace
+ c, n = path.reduce([ApplicationController, Object]){|list, p|
+ c, n = list
+
+ if controller_or_helper == "controller"
+ c = if Object.const_defined? (p + 'Controller'), false
+ Object.const_get (p + 'Controller'), false
+ else
+ Object.const_set p + 'Controller', Class.new(c)
+ end
+ end
+
+ n = if n.const_defined? p, false
+ n.const_get(p, false)
+ else
+ n.const_set p, Module.new()
+ end
+ [c, n]
+ }
+
+ # ApplicationController を参照すると Helper が読み込まれるので
+ # 必要な Controller, Helper をその前に登録する
+
+ if controller_or_helper == "controller"
+ new_class = Class.new(c)
+ else
+ new_class = Module.new()
+ end
+
+ #
+ n.const_set name, new_class
+
+ # 新しく作ったクラス・モジュールに必要な機能を追加
+ new_class.class_eval do
+ # TrailedParanoidScaffold::Controller
+ # TrailedParanoidScaffold::Helper
+ # TrailedParanoidScaffold::HistoriesController
+ # TrailedParanoidScaffold::HistoriesHelper
+ # を include する
+ include TrailedParanoidScaffold.const_get(
+ (histories ? "Histories" : "") + controller_or_helper.classify
+ )
+
+ # クラスメソッド tpsf を追加
+ # カラム名などに関する情報が格納される
+ @tpsf = {
+ model: model,
+ model_id: ( histories ? "#{model}/history".to_sym : model.to_sym )
+ }
+ def @tpsf.method_missing(name, *other)
+ if has_key? name
+ self[name]
+ else
+ super name, *other
+ end
+ end
+ def self.tpsf
+ @tpsf
+ end
+
+ # モデル名も計算しておく
+ if controller_or_helper == "controller"
+ @active_scaffold_model =
+ histories ? "#{model}/history".to_sym : model.to_sym
+ else
+ # ヘルパにユーティリティ関数を定義する
+ # 例えば def_column を使うと、
+ # def_column(:column_name) do |record, column|
+ # # def {record_name}_{column_name}_column(record, column)
+ # # として定義するのと同じ結果を得られる
+ # end
+ [:column, :column_attributes,
+ :form_column, :show_column, :search_column].each do |fname|
+ new_class.class_eval <<-"EOS"
+ def self.def_#{fname}(name, &block)
+ define_method :"#{model.underscore}_\#{name}_#{fname}", &block
+ end
+ EOS
+ end
+
+ end
+
+ # 与えられたブロックをクラス・モジュールのスコープで評価
+ new_class.class_eval &block if block
+ end
+
+ end
+
+ # 必要な Model / Controller / Helper が定義されていなければ定義する
+ def self.build_all(path)
+ path =~ /^\/((.*)\/)?([^\/]+)$/
+ model = $3
+ path = $1 || ''
+
+ # Model::History
+ TrailedParanoidScaffold::unless_defined(model + '/history') do |name|
+ model.classify.constantize.class_eval do
+ include TrailedParanoidScaffold::Model
+ end
+ end
+
+ # Model::HistoriesHelper
+ unless_defined(path + model + '/histories_helper') do |name|
+ TrailedParanoidScaffold.build_sub(name) { }
+ end
+
+ # ModelsHelper
+ TrailedParanoidScaffold::unless_defined(path + model.pluralize + '_helper') do |name|
+ TrailedParanoidScaffold.build_sub(name) { }
+ end
+
+ # ModelsController
+ unless_defined(model.pluralize + '_controller') do |name|
+ TrailedParanoidScaffold.build_sub(path + name) do |conf|
+ # 自動的には読み込まれないため手動でヘルパーを読み込む
+ add_template_helper (path + model.pluralize + '_helper').classify.constantize
+
+ # active_scaffold を呼ぶ
+ active_scaffold @active_scaffold_model
+ end
+ end
+
+ # Model::HistoriesController
+ unless_defined(model + '/histories_controller') do |name|
+ TrailedParanoidScaffold.build_sub(path + name) do |conf|
+ # 自動的には読み込まれないため手動でヘルパーを読み込む
+ add_template_helper (path + model + '/histories_helper').classify.constantize
+
+ # active_scaffold を呼ぶ
+ active_scaffold @active_scaffold_model
+ end
+ end
+ end
+
+ # id.classify で指定された定数が見つからなければ与えられたブロックを実行する
+ # ブロックには指定された定数が渡される
+ def self.unless_defined(id)
+ defined = false
+ begin
+ id.classify.constantize
+ # was defined
+ defined = true
+ rescue NameError
+ # was not defined
+ end
+
+ yield id unless defined
+ end
+
+ end
+
+ module ActionDispatch
+ module Routing
+ class Mapper
+ module Base
+ # trails_paranoid_scaffold 用の as_routes
+ #
+ # options には、
+ # options[:histories_resources] = {}
+ # options[:histories_routes] = {}
+ # の形で、下位層へのオプションも与えられる
+ #
+ def as_tpsf_routes(options = {:association => true})
+ options = options.dup.stringify_keys
+
+ histories_resources = {
+ controller: "#{@scope[:controller].singularize}/histories"
+ }.merge(options.delete(:histories_resources) || {})
+
+ histories_routes = {
+ :association => true
+ }.merge(options.delete(:histories_routes) || {})
+
+
+ ### ここからが実際のルート指定
+
+ # active_scaffold の基本
+ as_routes options
+
+ # 消去済みレコードの復帰用アクション
+ member do
+ put 'restore'
+ end
+
+ # histories へのルート
+ resources :histories, histories_resources do
+ as_routes histories_routes
+ end
+
+ # 必要な Controller / Helper を定義する
+ TrailedParanoidScaffold::build_all(( @scope[:path] || '' ) + '/' + @scope[:controller].singularize)
+ end
+
+ end
+ end
+ end
+ end
+
+paranoid のためのカラムを追加
+
+ LANG:console
+ $ rails generate migration AddDeletedAtToTests deleted_at:datetime:index
+ $ rake db:migrate
+
+confit/routes.rb
+ LANG:ruby
+ # resources :tests, concerns: :active_scaffold
+ resources :tests, concerns: :active_scaffold do
+ as_tpsf_routes
+ end
+
+これだけで動くようにした。
+
+History や Controller, Helper は定義されていなければ勝手に定義する。
+
+** Controller や Helper に手を加えたい場合 [#o890da96]
+
+app/controllers/tests_controller.rb
+ LANG:ruby
+ TrailedParanoidScaffold::build(__FILE__) do
+ active_scaffold @active_scaffold_model do |conf|
+ # ここに active_scaffold の column 定義など
+ end
+ # ここに追加の action など
+ end
+
+app/helpers/tests_helper.rb
+ LANG:ruby
+ TrailedParanoidScaffold::build(__FILE__) do
+ # ここに追加の設定を
+ end
+
+app/controllers/test/histories_controller.rb
+ LANG:ruby
+ TrailedParanoidScaffold::build(__FILE__) do
+ active_scaffold @active_scaffold_model do |conf|
+ # ここに active_scaffold の column 定義など
+ end
+ # ここに追加の action など
+ end
+
+app/helpers/test/histories_helper.rb
+ LANG:ruby
+ TrailedParanoidScaffold::build(__FILE__) do
+ # ここに追加の設定を
+ end
+
+
+** 時刻の表示方法を設定 [#y5977f34]
+
+https://ja.stackoverflow.com/questions/8161/created-at%E3%81%AE%E3%82%BF%E3%82%A4%E3%83%A0%E3%82%BE%E3%83%BC%E3%83%B3%E3%81%A8%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%83%E3%83%88%E3%82%92%E5%A4%89%E6%8F%9B%E3%81%99%E3%82%8B を参考に
+
+config/application.rb
+ LANG:ruby
+ module Album
+ class Application < Rails::Application
+ ...
+
+ + config.time_zone = 'Tokyo'
+ + config.i18n.default_locale = :ja
+ end
+ end
+
+config/locales/ja.yml
+ LANG:ruby
+ + ja:
+ + time:
+ + formats:
+ + default: ! '%Y/%m/%d %H:%M:%S'
+
* 質問・コメント [#t616f744]
#article_kcaptcha