ActionView is a very useful class, in its own right. But, calling it by itself causes a weird crash, exiting Ruby, without even raising an exception! ruby script/runner "begin; av = ActionView::Base.new; av.render(:inline => ''Hi!''); rescue => e; puts e; end" just crashes Ruby. Same with render(:file => ''template.rhtml'') Why is this? What is the proper way to use ActionView to render a template? -- Posted via http://www.ruby-forum.com/.
Oops. Forgot the "puts". Works fine when rendering inline templates. But I can''t get the same syntax to work to render :file => filename. Robert James wrote:> ActionView is a very useful class, in its own right. But, calling it by > itself causes a weird crash, exiting Ruby, without even raising an > exception! > > ruby script/runner "begin; av = ActionView::Base.new; av.render(:inline > => ''Hi!''); rescue => e; puts e; end" > > just crashes Ruby. > > Same with render(:file => ''template.rhtml'') > > Why is this? > > What is the proper way to use ActionView to render a template?-- Posted via http://www.ruby-forum.com/.
I did more testing, and think I may have found a bug: You can use ActionView freestyly to do compile_and_render_template - but, if you give it a file to load itself, Ruby crashes. No exception, no error, just the intepreter exits. (I''m running Windows. Perhaps on Linux it would dump core?). Example: av = ActionView::Base.new t = "/path/to/template/file.rhtml" av.render_file(t, false) # crash -- Posted via http://www.ruby-forum.com/.
Robert James wrote:> I did more testing, and think I may have found a bug: > > You can use ActionView freestyly to do compile_and_render_template - > but, if you give it a file to load itself, Ruby crashes. No exception, > no error, just the intepreter exits. > > (I''m running Windows. Perhaps on Linux it would dump core?). > > Example: > > av = ActionView::Base.new > t = "/path/to/template/file.rhtml" > av.render_file(t, false) > # crashWhat does everyone else get? A crash, or does it work? -- Posted via http://www.ruby-forum.com/.
Robert James wrote on 14.07.2006 23:32:> Robert James wrote: >> I did more testing, and think I may have found a bug: >> >> You can use ActionView freestyly to do compile_and_render_template - >> but, if you give it a file to load itself, Ruby crashes. No exception, >> no error, just the intepreter exits. >> >> (I''m running Windows. Perhaps on Linux it would dump core?). >> >> Example: >> >> av = ActionView::Base.new >> t = "/path/to/template/file.rhtml" >> av.render_file(t, false) >> # crash > > What does everyone else get? A crash, or does it work? >With the above code an error: test.rb(main):008:0* av = ActionView::Base.new() => #<ActionView::Base:0xb7a793f8 @assigns={}, @base_path=nil, @logger=nil, @assigns_added=nil, @controller=nil> test.rb(main):009:0> t = "test.rhtml" => "test.rhtml" test.rb(main):010:0> av.render_file(t, false) Exception `TypeError'' at /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_view/base.rb:477 - can''t convert nil into String But with a set base_path it works: test.rb(main):008:0* av = ActionView::Base.new(''.'') => #<ActionView::Base:0xb7ae1bac @assigns={}, @base_path=".", @logger=nil, @assigns_added=nil, @controller=nil> test.rb(main):009:0> t = "test.rhtml" => "test.rhtml" test.rb(main):010:0> av.render_file(t, false) => "<html>\n</html>\n" Hope it helps... Markus
Must be a windows issue - I still get a Ruby crash - not even an exception, the intepreter just crashes. What OS are you running? Markus Kolb wrote:> But with a set base_path it works: > > test.rb(main):008:0* av = ActionView::Base.new(''.'') > => #<ActionView::Base:0xb7ae1bac @assigns={}, @base_path=".", > @logger=nil, @assigns_added=nil, @controller=nil> > test.rb(main):009:0> t = "test.rhtml" > => "test.rhtml" > test.rb(main):010:0> av.render_file(t, false) > => "<html>\n</html>\n"-- Posted via http://www.ruby-forum.com/.
Robert James wrote:> Must be a windows issue - I still get a Ruby crash - not even an > exception, the intepreter just crashes. What OS are you running? > > Markus Kolb wrote: >> But with a set base_path it works: >> >> test.rb(main):008:0* av = ActionView::Base.new(''.'') >> => #<ActionView::Base:0xb7ae1bac @assigns={}, @base_path=".", >> @logger=nil, @assigns_added=nil, @controller=nil> >> test.rb(main):009:0> t = "test.rhtml" >> => "test.rhtml" >> test.rb(main):010:0> av.render_file(t, false) >> => "<html>\n</html>\n"Can someone else with ruby on Windows try running this and see if Ruby crashes for them? -- Posted via http://www.ruby-forum.com/.
Robert James wrote:> Robert James wrote: >> Must be a windows issue - I still get a Ruby crash - not even an >> exception, the intepreter just crashes. What OS are you running? >> >> Markus Kolb wrote: >>> But with a set base_path it works: >>> >>> test.rb(main):008:0* av = ActionView::Base.new(''.'') >>> => #<ActionView::Base:0xb7ae1bac @assigns={}, @base_path=".", >>> @logger=nil, @assigns_added=nil, @controller=nil> >>> test.rb(main):009:0> t = "test.rhtml" >>> => "test.rhtml" >>> test.rb(main):010:0> av.render_file(t, false) >>> => "<html>\n</html>\n" > > Can someone else with ruby on Windows try running this and see if Ruby > crashes for them?I''m getting this very same problem. Basically, when ActionView tries to raise an exception because it can''t find the file to render, if it was invoked freestyle, it crashes rather than produce an error. Only in Windows though. -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Apparently Analagous Threads
- ActionView::TemplateError
- Odd error handling in ActionView#compile_template causes WSOD
- Rails 2.2.2 and globalize - undefined method `render_file' for class `ActionView::Base' (NameError)
- undefined method `each'' for nil:NilClass with Ferret search
- undefined method 'render_file' for class 'ActionView::Base'