controllers/application.rb とかに以下のように記述する。
ActiveScaffold.set_defaults do |config|
config.list.per_page = 20
end
config.list.per_page でなくて,config.list.results_per_page と書くとエラーになるので要注意。
ActiveScaffold :: API: List
ActiveScaffold.set_defaults do |config|
config.list.per_page = 20
end
Connecting to xxxxx.strongspace.com...
Address 4.71.165.121 maps to 4-71-165-121.revdns.textdrive.com,
but this does not map back to the address
- POSSIBLE BREAKIN ATTEMPT!
% host 4-71-165-121.revdns.textdrive.com
4-71-165-121.revdns.textdrive.com has address 207.7.108.21
% host 207.7.108.21
21.108.7.207.in-addr.arpa domain name pointer one.textdrive.com.
class UsersController < ApplicationController
active_scaffold :user do |conf|
conf.action_links.add 'export_csv', :label => 'Export to Excel', :page => true
end
def export_csv
# find_page is how the List module gets its data. see Actions::List#do_list.
records = find_page().items
return if records.size == 0
# Note this code is very generic. We could move this method and the
# action_link configuration into the ApplicationController and reuse it
# for all our models.
data = ""
cls = records[0].class
data << cls.csv_header << "\r\n"
records.each do |inst|
data << inst.to_csv << "\r\n"
end
send_data data, :type => 'text/csv', :filename => cls.name.pluralize + '.csv'
end
end
モデルの変更点。
class User < ActiveRecord::Base
# The header line lists the attribute names. ID is quoted to work
# around an issue with Excel and CSV files that start with "ID".
def self.csv_header
"ID,Last Name,First Name, Email, Birthdate"
end
# Emit our attribute values as a line of CSVs
def to_csv
id.to_s << "," << last_name << "," << first_name << "," << email
<< "," << birthdate.to_s
end
end
./script/plugin install \
http://activescaffold.googlecode.com/svn/branches/upload
public/entry/filename
public/entry/filename/1
public/entry/filename/2
.
.
.
file_column :filename, {:fix_file_extensions => nil}
./script/plugin install http://activecalendar.googlecode.com/svn/trunk/activecalendar
<%= stylesheet_link_tag "/javascripts/jscalendar-1.0/calendar-win2k-cold-1.css" %>
<%= javascript_include_tag "jscalendar-1.0/calendar.js" %>
<%= javascript_include_tag "jscalendar-1.0/lang/calendar-en.js" %>
<%= javascript_include_tag "jscalendar-1.0/calendar-setup.js" %>
Rails::Initializer.run do |config|
..中略..
# config.plugins = %W( exception_notification ssl_requirement )
config.plugins = ["engines", "*"]
..中略..
end
require File.join(RAILS_ROOT, "vendor", "plugins", "engines", "lib", "engines", "deprecated_config_support")
module LoginEngine
config :salt, "mysalt"
config :email_from, "foo@company.co.jp"
config :admin_email, "foo@company.co.jp"
config :app_name, "ermgr"
end
#Engine.start :login
rake engine_migrate ENGINE=login
$ script/generate plugin_migration
create db/migrate
create db/migrate/001_login_engine_to_version_1.rb
plugin_schema_info
schema_info
$ rake db:migrate ENGINE=login
(in /home/kaori/ermgr)
== LoginEngineToVersion1: migrating ===========================================
== InitialSchema: migrating ===================================================
-- create_table("users", {:force=>true})
-> 0.1120s
== InitialSchema: migrated (0.1130s) ==========================================
== LoginEngineToVersion1: migrated (0.1780s) ==================================