Hi
Since I am noob with ruby still I have question. This is my setup.
2 tables and their fields.
Users table
login
imitem_id
Imitems table
id
groupname
Now all users have several Imitems and those are saved on user table
with imitem_id which points back to
id on Imitems table.
Now on Imitem controller I have action:
def welcome
loginname = request.env[‘REMOTE_USER’]
@users = User.find(:all, :conditions => [ “login = ?”, loginname])
end
ie. it finds all users who’s loginname is the same as their
REMOTE_USER name
and on welcome.html.erb page it will print out all those entries which
match that sql query.
<% form_for :user, @user, :url => { :action => “select” }, :html =>
{:id => ‘g
rpform’, :name => ‘grpform’, :target => ‘_parent’, :onsubmit =>
‘return validate_task(this);’ } do |f| %>
<% for user in @users %>
<% end %>
<% end %>
Now however I need to print out also respective group name from Imitem
table where loop
<% for user in @users %>
loops thru user items and then it should find out match for the items
where
user.imitem_id == imitem.id (and then return imitem.groupname)
ie. when user imitem.id number is equal to the imitem.id then I should
find out what is that groupname on
imitem table ?
Any ideas ?