methods in my models working in console but not in app itself... help :-)

I am going crazy. I have the below two methods in my tag model.
Within the console my Tag.create_for :location => "Toronto" works but
soon as I put this code in my application I get the following error:
NoMethodError in UserController#set_user_fetish_list; undefined method
`make_url_safe' for Tag:Class

Does that make sense.. especially since in works in the console? HELP! :slight_smile:

class Tag < ActiveRecord::Base
  def Tag.create_for(options)
    if options[:fetish]
      self.create(:name => options[:fetish], :url_safe =>
make_url_safe(), :category => "fetish")
    elsif options[:location]
      self.create(:name => options[:location], :url_safe =>
make_url_safe(options[:location]), :category => "location")
    end
  end

  private
  def make_url_safe(str)
    str.gsub(/\s/, "_")
  end
end

Thanks for your help! :slight_smile:

you're trying to call an instance method from a class method.

define it as

def Tag.make_url_safe(str)

and you should be good to go.

great! thanks :slight_smile: