Rails 3.1.3

I get the following error when Ajax 'save' action is executed.



Started POST "/scripts" for 127.0.0.1 at 2012-02-16 09:23:05 +0900
  Processing by ScriptsController#create as JS
  Parameters: {"utf8"=>"✓",
"authenticity_token"=>"9rMiPwxlQrXiAIgUy8Qqe77KXDezXmpLF4WLupZb5ME=",
"script"=>{"video_id"=>"18", "startp"=>"37", "text"=>"eeeeee"},
"commit"=>"save"}
   (0.1ms)  SELECT 1 FROM "scripts" WHERE "scripts"."startp" = 37 LIMIT
1
Completed 500 Internal Server Error in 15ms

NoMethodError (undefined method `script' for
#<Script:0x00000103202868>):
  app/controllers/scripts_controller.rb:44:in `block in create'
  app/controllers/scripts_controller.rb:43:in `create'


It says 'NoMethodError', but in the controller,


  def create
    @script = Script.new(params[:script])
    respond_to do |format|
      if @script.save                             #<=44: HERE!!!!!
        format.html { redirect_to @script, notice: 'Script was
successfully added.' }
        format.json { render json: @script, status: :created, location:
@script }
      else
        format.html { render action: "new" }
      end
    end

'script' is not defined?  I have no clue.

save.js.erb has the following.

    $('#listtrans').html('<%= escape_javascript(render :partial =>
"script_list", :locals => {:scripts => @video.scripts} ) %>');

Does anyone have any clue?

soichi

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to