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 %> <tr><td><%= h(user.imitem_id) %></td><td></td><td></td><td></td><td>< %= link_t o ''Destroy'', user, :confirm => ''Are you sure you want to cancel this group sub scription ?'', :method => :delete %> [Edit] [MDM disable]</td></tr> <% 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 ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
first of all, there is no request.env[''REMOTE_USER'']. it just does not work that way. Have a look at acts_as_authenticated and install and use that. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Well there is and it works fine. But thats not the thing what I am asking here. You can think that loginname request.env[''REMOTE_USER''] could be anything like loginname=jane On Feb 11, 2:13 pm, Ryan Bigg <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> first of all, there is no request.env[''REMOTE_USER'']. it just does not > work that way. Have a look at acts_as_authenticated and install and use > that.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
and I figured it out <% @imitems.each do |imitem| %> <% if imitem.id == user.imitem_id %> <%= imitem.grpname %> <% end %> <% end %> also needed to add on models user.rb has_many :imitems imitem.rb belongs_to :user On Feb 11, 2:37 pm, KTU <ketuo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Well there is and it works fine. But thats not the thing what I am > asking here. You can think that loginname > request.env[''REMOTE_USER''] > could be anything like loginname=jane > > On Feb 11, 2:13 pm, Ryan Bigg <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > first of all, there is no request.env[''REMOTE_USER'']. it just does not > > work that way. Have a look at acts_as_authenticated and install and use > > that.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I didn''t believe that and I even tested it myself. I put: "puts request.env[''REMOTE_USER'']" in my blogs_controller index action and checked it in Firefox on Windows XP It returned nil. I checked it on IE7 on WindowsXP It returned nil. I checked it on Firefox in Ubuntu. It returned nil. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---