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?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---