第一个问题:
Processing Admin::AdminWysisController#create (for ::1 at 2010-06-22 13:43:58) [POST]
Parameters: {"commit"=>"save", "action"=>"create", "authenticity_token"=>"P8pW7GnSNr7RZcxFcejpfsu9YCX7z8hO0DJPH3rYalQ=", "controller"=>"admin/admin_wysis", "admin_wysi"=>{"post_published"=>"<p>\r\n\tstinky</p>\r\n"}}
User Columns (2.0ms) SHOW FIELDS FROM `users`
User Load (0.3ms) SELECT * FROM `users` WHERE (`users`.`id` = '1') LIMIT 1
SQL (0.1ms) BEGIN
User Update (0.2ms) UPDATE `users` SET `updated_at` = '2010-06-22 17:43:58', `perishable_token` = 'XMxt1yi5_4JEwPP-21GO', `last_request_at` = '2010-06-22 17:43:58' WHERE `id` = 1
SQL (0.4ms) COMMIT
AdminWysi Columns (1.0ms) SHOW FIELDS FROM `admin_wysis`
SQL (0.1ms) BEGIN
AdminWysi Create (0.1ms) INSERT INTO `admin_wysis` (`post_published`) VALUES(NULL)
SQL (0.4ms) COMMIT
Redirected to http://localhost:3000/admin/admin_wysi
Completed in 139ms (DB: 5) | 302 Found [http://localhost/admin/admin_wysi]
SQL (0.1ms) SET NAMES 'utf8'
SQL (0.1ms) SET SQL_AUTO_IS_NULL=0
这句话最重要的部分是:
"admin_wysi"=>{"post_published"=>"<p>\r\n\tasdfasdfasd</p>\r\n"}
这应该很简单:
"post_published"=> "<p>\r\n\tasdfasdfasd</p>\r\n"
让我们看看我的观点。。
- form_for @admin_wysi, :url => admin_admin_wysi_path do |f|
= f.error_messages :header_message => FORM_ERROR_HEADER_MESSAGE, :message => FORM_ERROR_MESSAGE
= f.cktext_area :post_published, :cols => '70', :rows => '30', :width => '555px', :height => '240px', :toolbar => 'HQ'
%br/
.grid_2.prefix_5.align_right
= f.submit 'save', {:class => 'button'}
这是我的控制器:D
def new
@admin_wysi = AdminWysi.new
end
def create
@admin_wysi = AdminWysi.new(params[:admin_wysi])
if @admin_wysi.save
redirect_to admin_admin_wysi_path
end
end
第二个问题
奇怪的是,当它保存时,它会将我重定向到website.com/wysi而不是website.com/wysis/。后者是一个工作环节,前者不是一个真正的环节。
map.namespace :admin do |admin|
admin.resource :admin_wysi
end