Louis Wrobel
2011-May-27 12:21 UTC
undefined method `model_name'' for NilClass:Class in a form_for
Hi! I know that there are other topics about this issue, I read them and I''m always blocked. Here is the error message: undefined method `model_name'' for NilClass:Class Extracted source (around line #30): 27: 28: <h2>Add Translation</h2> 29: 30: <%= form_for @new_trad do |f| %> 31: Locale: <%= f.text_field :locale %> 32: Key : <%= f.text_field :key %> 33: Value : <%= f.text_field :value %> The new method in TranslationsController: def new @new_trad = Translations.new end Tell me if other informations are needed. Thanks in advance! ps: Sorry for my bad english :) -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling
2011-May-27 12:25 UTC
Re: undefined method `model_name'' for NilClass:Class in a form_for
On 27 May 2011 13:21, Louis Wrobel <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> undefined method `model_name'' for NilClass:Class > > 30: <%= form_for @new_trad do |f| %>This means that the @new_trad object is probably nil.> def new > @new_trad = Translations.new > endJust a guess, but you might want: @new_trad = Translation.new If that''s not it, I''d recommend checking out the guides on debugging and put a breakpoint in the view. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Louis Wrobel
2011-May-27 13:23 UTC
Re: undefined method `model_name'' for NilClass:Class in a form_for
Michael Pavling wrote in post #1001495:> Just a guess, but you might want: > @new_trad = Translation.newNo, it''s Translations and I forgot to tell that it''s not an ActiveRecord model. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling
2011-May-27 13:31 UTC
Re: Re: undefined method `model_name'' for NilClass:Class in a form_for
On 27 May 2011 14:23, Louis Wrobel <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Michael Pavling wrote in post #1001495: > >> Just a guess, but you might want: >> @new_trad = Translation.new > > No, it''s Translations and I forgot to tell that it''s not an ActiveRecord > model.Right... so the form_for stuff won''t work then, unless you add all the methods it needs that a "normal" model would inherit from AR::Base (or probably won''t work at all - use a form_tag instead...) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Louis Wrobel
2011-May-27 14:45 UTC
Re: Re: undefined method `model_name'' for NilClass:Class in a form_for
Michael Pavling wrote in post #1001516:> Right... so the form_for stuff won''t work then, unless you add all the > methods it needs that a "normal" model would inherit from AR::Base (or > probably won''t work at all - use a form_tag instead...)Thanks you, i tried with form_tag and it works. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Maybe Matching Threads
- undefined method `model_name' for NilClass:Class in rails 3.0.0
- undefined method `model_name' for NilClass:Class
- gmaps4rails: undefined method `model_name' for NilClass:Class
- undefined method `model_name' for NilClass:Class
- [rails] undefined method `model_name' for NilClass:Class