call controller methods from view

Hi Mohamed, as John Miller points out this is easier done from the controller and also recommended as a best practice. Here’s a simple (un-tested) example of how to assign and access instance variables (@…) from a controller and view:

Class SummeryController < ApplicationController

def list

    @user

= User.find(1) # if you’re using act_as_authenticate,

          # you

could have something here like: user = self.current_user

    @userProjects

= Projects.find(:all, :conditions => [“user_id = ?”, @user.id])

end

list.rhtml

<% for project in @userProjects %>

    <%=

project.name %>

<% end %>

Regards,

Dave