firelinemx
2009-Aug-07 13:24 UTC
render views from outside of controller for example in my modules in Lib directory
i render view from outside of controllers in my a module in lib folder, here is my render method: def render(options, assigns = {}) view = ActionView::Base.new (ActionController::Base.view_paths,assigns) view.render options end and i call it like this: render(:file=>"#{template_path}.html.erb",:locals => locals) every things fine in rendered page, i can use locals but when i use FORM_FOR in rendered view, i get this error message: You have a nil object when you didn''t expect it! The error occurred while evaluating nil.url_for please help me!
firelinemx
2009-Aug-07 13:24 UTC
render views from outside of controller for example in my modules in Lib directory
i render view from outside of controllers in my a module in lib folder, here is my render method: def render(options, assigns = {}) view = ActionView::Base.new (ActionController::Base.view_paths,assigns) view.render options end and i call it like this: render(:file=>"#{template_path}.html.erb",:locals => locals) every things fine in rendered page, i can use locals but when i use FORM_FOR in rendered view, i get this error message: You have a nil object when you didn''t expect it! The error occurred while evaluating nil.url_for please help me!
Ilan Berci
2009-Aug-07 15:15 UTC
Re: render views from outside of controller for example in my modules in Lib directory
firelinemx wrote:> i render view from outside of controllers in my a module in lib > folder, here is my render method: > > def render(options, assigns = {}) > view = ActionView::Base.new > (ActionController::Base.view_paths,assigns) > view.render options > end > > and i call it like this: > render(:file=>"#{template_path}.html.erb",:locals => locals) > > every things fine in rendered page, i can use locals but when i use > FORM_FOR in rendered view, i get this error message: > > You have a nil object when you didn''t expect it! > The error occurred while evaluating nil.url_for > > please help me!Not a fan of any rendering showing up in your models but in your controller code, did you assign the model of interest to your locals? i.e. does the locals() in :locals => locals bring up your model of interest.. as that is what you are passing to the view. -- Posted via http://www.ruby-forum.com/.