John Kopanas
2006-Sep-07 04:57 UTC
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! :-) 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! :-) -- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Chris Hall
2006-Sep-07 15:04 UTC
Re: methods in my models working in console but not in app itself... help :-)
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. On 9/7/06, John Kopanas <kopanas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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! :-) > > 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! :-) > > -- > John Kopanas > john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
John Kopanas
2006-Sep-07 17:48 UTC
Re: methods in my models working in console but not in app itself... help :-)
great! thanks :-) On 9/7/06, Chris Hall <christopher.k.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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. > > On 9/7/06, John Kopanas <kopanas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > 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! :-) > > > > 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! :-) > > > > -- > > John Kopanas > > john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org > > > > > > > > > > >-- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---