Take the tour ×

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'

The most important part of that statement is this one :


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.submit 'save', {:class => 'button'}

Here is my controller :D

def new
 @admin_wysi = AdminWysi.new

def create
  @admin_wysi = AdminWysi.new(params[:admin_wysi])
  if @admin_wysi.save
    redirect_to admin_admin_wysi_path

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
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

The params you're getting are what's expected in a Rails app. Otherwise, there would be no good way to access only the parameters that are part of the object to the save (for instance, to discard the commit, action, etc. key/value pairs). What errors are you getting from the create action? If it's redirecting you, it seems like it is probably not getting errors while saving.

As to your routing problem, the reason you're getting the singular (wysi) rather than plural (wysis) is that you're using map.resource instead of map.resources. If you change that, I believe it should fix the routing problem.

share|improve this answer
thanks so much for your response. I made it plural. No worries there, that helped. Also, above I included the full SQL statement. You can see there are no errors, and the one I had originally up there is actually an accepted way to add data. Notice though in the statement this line <<<<< INSERT INTO admin_wysis (post_published) VALUES(NULL) >>>> Interesting? Not sure what that means.. Anyways, thanks so much. –  Trip Jun 22 '10 at 19:22
Haha..why would a default rails migration make a table cell null? –  Trip Jun 22 '10 at 19:35
Turns out I had a attr_accessor :post_published in my model that made it so that anything written into that field ended up blank. –  Trip Jun 22 '10 at 19:42
add comment

Your Answer


