I haven't tried this before, and my suggestion hasn't been tested but with the last one, try this:
string = ActionController::Base.new.send(:render, :template => 'cont/index') AFAIK the send method can be used to call private and protected methods so this should work. Hope that helps! -- Josh http://iammrjoshua.com Konstantin wrote: > Hello! > > In my application I'm trying to render a view from a class in /lib > folder. I have found that it's very similar to render a view from > console. So, I have tried different methods: >>> string = ActionView::Base.new.render( :inline => 'works', :layout => false ) > => "works" >>> string = ActionView::Base.new.render( :template => 'contr/index', :layout >>> => false ) > => nil >>> string = ActionView::Base.new.render( :controller => 'contr', :action => >>> 'index', :layout => false ) > => nil >>> string = ActionView::Base.new.render( :file => 'contr/index', :layout => >>> false ) > ActionView::MissingTemplate: Missing template contr/index.html.erb in > view path >>> string = ActionController::Base.new.render( :template => 'contr/index' ) > NoMethodError: protected method `render' called for # > > So, nothing works except :inline templates. I saw a similar solution > like ERB.new("Hello, <%= name %>").result(binding) - but it's not > suitable for me because I need to read a template and then insert it > here. > > Could you suggest how can I render a template? -- 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

