Render No Layout?


#1

Hi guys,

Am having a problem.

I have this def in my index controller that works like this:

def do_something

$a = variable1
$b = variable2
$c = variable3
$d = “”<script language=“Javascript”> \n new Insertion.Bottom(’#{$c}’,
‘#{$a} - #{$b}’); \n "

$trigger = “1”

render(:partial => “do_something”)

end

on my do_something.rhtml, my code is this:
<% if $trigger == “1” %>
<%=$d %>
<% $trigger = “0” %>
<% return %>
<% end %>

I get a render with no layout error message. What am I doing wrong?

thanks in advance!

Bing


#2

On 17/05/06, Bing removed_email_address@domain.invalid wrote:

on my do_something.rhtml, my code is this:
<% if $trigger == “1” %>
<%=$d %>
<% $trigger = “0” %>
<% return %>
<% end %>

I get a render with no layout error message. What am I doing wrong?

Just guessing, but is it because you have that ‘return’ in your
do_something.rhtml?

David


#3

Bing wrote:

$c = variable3
<% if $trigger == “1” %>
<%=$d %>
<% $trigger = “0” %>
<% return %>
<% end %>

I get a render with no layout error message. What am I doing wrong?

Partials should be named with a beginning underscore _do_something.rhtml

More likely you want to just take the render(:partial => “do_something”)
out of your controller. The default is for every controller action that
doesn’t redirect to render a template with the same name as the action,
so the do_something action will render the do_something.rhtml template.

If you want to specific a different template, use render(:action =>
“template_name”)

Ray


#4

Hi David,

I need the <%return%> on my rhtml so that I can exit out of my if
condition.

Hi Ray,

Sorry, but yes, our render partial rhtml does have the underscore. so
the page is called _do_something.rhtml. Just the same we had already
used render(:action with no success.

Also, if I may add, def do_something is being executed by a
periodical_call_remote function.

Bing


#5

Bing wrote:

Hi David,

I need the <%return%> on my rhtml so that I can exit out of my if
condition.

Hi Ray,

Sorry, but yes, our render partial rhtml does have the underscore. so
the page is called _do_something.rhtml. Just the same we had already
used render(:action with no success.

Also, if I may add, def do_something is being executed by a
periodical_call_remote function.

Bing

You don’t need a return statement in the if condition.

j`ey
http://www.eachmapinject.com
(c=“amBleQ==\n”).unpack(c[1…1]).pop


#6

j`ey wrote:

Bing wrote:

Hi David,

I need the <%return%> on my rhtml so that I can exit out of my if
condition.

Hi Ray,

Sorry, but yes, our render partial rhtml does have the underscore. so
the page is called _do_something.rhtml. Just the same we had already
used render(:action with no success.

Also, if I may add, def do_something is being executed by a
periodical_call_remote function.

Bing

You don’t need a return statement in the if condition.

j`ey
http://www.eachmapinject.com
(c=“amBleQ==\n”).unpack(c[1…1]).pop

Took out the return, doesn’t do squat. The main thing I guess is, I
don’t see which section does the first render and which section does the
2nd render. there was no explicit statement in the code to make a second
render.


#7

On May 17, 2006, at 1:49 AM, Bing wrote:

$c = variable3
on my do_something.rhtml, my code is this:
Bing
Bing-

Is there any reason you are using global variables? vars with the $

sign are global and can have unexpected behavior when you use them
like you are right now. You should be using instance @vars instead,
the ones with the @ sign.

-Ezra


#8

Bing wrote:

Sorry, but yes, our render partial rhtml does have the underscore. so
the page is called _do_something.rhtml. Just the same we had already
used render(:action with no success.

When you user render :action, the template doesn’t begin with an
underscore, correct?

Also, if I may add, def do_something is being executed by a
periodical_call_remote function.

Ah. So you have

controller

def periodical_call_remote_function
do some stuff
do_something
What’s here?
end

def do_something
some more stuff defining @thing
render :action => ‘do_something’
end

view

do_something.rhtml

<% display @thing %>

Do you have a periodical_call_remote_function.rhtml?

Ray


#9

The reason I needed to use global variable for the def was because we
needed to pass the value of the variable to the rhtml. Setting it with @
doesn’t allow me to do that. We tested it again to make sure and true
enough, while variable c was $c, the values were being passed. When @c,
the values weren’t.

You have to manage to make it work with @ then! afaik it’s really the
way it
should be done (
http://api.rubyonrails.com/classes/ActionController/Base.html)

Could you post a repro of your issue with @ variables ? (maybe use
longer
variable names also). This way we may be able to understand what’s
happening
in there.

Really, you shouldn’t use those global variables for this or you’ll get
unexpected things (“I see dead people” and stuff :slight_smile:

hth

Thibaut


#10

Hi Ezra,

The reason I needed to use global variable for the def was because we
needed to pass the value of the variable to the rhtml. Setting it with @
doesn’t allow me to do that. We tested it again to make sure and true
enough, while variable c was $c, the values were being passed. When @c,
the values weren’t.

Hi Ray,

my periodical call remote is actually found on my rhtml with this line
of code:

<%= periodically_call_remote(:update => 'divname', :url => { :action => :do_something}, :frequency => 3 ) %>

So it calls do_something from there.

Still having the doublerender! If I tried putting on the
“erase_render_results”, it doesn’t show the error but it also doesn’t
show what I needed to render. It’s driving me nuts!

Regards,

Bing