Felix
Felix

Reputation: 5619

rails passing a local variable to a partial got some errors

I'am trying to pass a local variable to a partial, but I got this error:

undefined local variable or method `blubb' for #<#<Class:0x00000007cb8c00>:0x00000007c79f78>

My code looks like this:

 <% rate = Rating.where(["comment_id = ? and movie_id = ?", comment.id, @movie.id]) %>

  <% @ratingvalue = rate[0][:ratingvalue] %>

 <div class="col-md-3 text-right"><%= render :partial => "shared/starRating", :locals => {blubb: @ratingvalue} %> </div>

When I inspect @ratingvalue there is my integer value inside.

Then in the partial I try to do this:

<%= blubb %>

but then I got the error.

also tried this:

<%= :blubb %>

but then only blubb is printed ...

What is going wrong?

Thanks for your help.

Upvotes: 0

Views: 80

Answers (1)

Nguyen Ruby
Nguyen Ruby

Reputation: 221

This code look fine, Btw you can try this:

<%= render :partial => "shared/starRating", :object => @ratingvalue %>

and in the partial you can using @ratingvalue variable.

Upvotes: 1

Related Questions