The error occured while evaluating nil.gsub!

#{RAILS_ROOT}/app/controllers/start_controller.rb:13:in `create’

class StartController < ApplicationController

def create

#------------Remove Tag---------------------------

@name = params[:name]
@file = params[:filepath]

@file = @file.gsub!(/^.*(\|/)/, ‘’) # replace html tags with blank

post = Post.save(@params[“removetag”])
end

end

The problem is with the ‘!’ in the gsub. That indicates that the
substitution should take place in the original string.

The cleanest solution is to simply remove the “@file =” from the front:

@file.gsub!(/^.*(\|/)/, ‘’) # replace html tags with blank

But you could also remove the ! and keep the variable assignment:

@file = @file.gsub(/^.*(\|/)/, ‘’) # replace html tags with blank

David
[email protected]

Then again, if I’d had my first cup of coffee already I’d have noticed
that the REAL problem is that @file is nil, so you’ll need to examine
how @file is set and test for it being set to nil before you do the
gsub.

DOH!

David S. (AFTER first cup of coffee…)
[email protected]