1st Question:
I'm trying to make the create method work, but it appears that my form is sending data innapropriately to my DB. This is the server.log :
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
The most important part of that statement is this one :
"admin_wysi"=>{"post_published"=>"<p>\r\n\tasdfasdfasd</p>\r\n"}
Which should be just simply :
"post_published"=> "<p>\r\n\tasdfasdfasd</p>\r\n"
Let's look at my view..
- 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'}
Here is my controller :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
Any idea what might be bugging this?
2nd Question
Strange as it is, when it saves, it redirects me to website.com/wysi NOT website.com/wysis/ . The latter one is a working link, the prior is not a real link.
My routes.rb looks like this :
map.namespace :admin do |admin|
admin.resource :admin_wysi
end