NoMethodError – undefined method `render_to_string’ for #<#:0x007f95255e3c08>:


Question#1 

Do I need to include anything special in order to call
render_to_string from the view?  When I try to do something like this
in my rhtml template:

<%= render_to_string(:partial => "user_description") %>

I get the error:

undefined method `render_to_string' for #<#<Class:0xb76e9134>:
0xb76e910c>

followed by an excerpt from my template.  Do I have something wrong
with the syntax?

Answers#1

I think I have found the answer-- apparently in the view templates,
you just call "render" and not "render_to_string".  The explanation
for this is probably that in the view you always want to render to a
string, but I'm not sure.

Question#2:

How to append  a partial in div?

Answer#2:
in view file:
 <%  @partial = render(:partial=> 'pages/content/call_text_phone', :formats=>[:html]) %>
in view file
<script type="text/javascript">

$(function(){

 $('#content_form_div').append("<%= j @partial%>");
 });

</script>
 
Advertisements

I am Senior Software Engineer. I love reading, writing, sharing,developing, hiking, movies, trips, mountains, brooks, hills etc.

Tagged with: , ,
Posted in Html, JQuery, Ruby Little Codes

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

StackOverFlow
Categories
Archives
%d bloggers like this: