views:

32

answers:

1

I am using the great Tequila-JSON Parser ( http://github.com/inem/tequila ) in an Web-application, to render more or less complex JSON server-replies. More and more the JSON-Templates (.jazz) are growing in somehow real "views". I am trying now, to get an instance-variable from the according controller, into the .jazz template, but this somehow fails.

Here is what I am trying to do.

The controller

def get_userlist

  @users = User.find(:all, :order => "value DESC", :limit => 10)    
  @user = User.find_by_email(params[:user_email])      
  @userid = @user.id # also tried: @userid = 2 

  respond_to do |format|
    format.json
  end
end

The .jazz view:

-@users
  :only
    .nickname
    .level
    .user_icon_url
    .email
    :methods
      .isfriend(@userid)
  +last_checkin
  +last_checkin_place
    :only
      .name
      .city

This all returns a pretty valid JSON server-reply, but unfortunately, there is a problem with the

:methods
  .isfriend(@userid)

The Method "isfriend" resides in the model "User", is called successfully and returns in the JSON, what it should. But the value of the instance-variable somehow is wrong. Opposed to the above, this one works fine:

:methods
  .isfriend(1)

Now the question: Is Tequila not able, to interpret instance-variables in its own .jazz templates? Does anyone have experience, solutions or workarounds?

For the sake of completeness, here is the isfriend method of the User-Model:

def isfriend(user_id)
  "Hi, I am User with the id: " + user_id.to_s
end
A: 

Nope. Also it doesn't work on Rails 3. I just spent 6 hours trying to port it and got basically nowhere :-(

Logan Koester