** RESOLVED ** If anyone else experiences something like this,
Original line of code: @posts = Post.find_by_user_id( session [:user_id], :order => "created_at DESC") change it to: @posts = Post.find_by_user_id( @user.id, :limit => 1, :order => "created_at desc") On 28 Nov, 19:57, RubyonRails_newbie <[email protected]> wrote: > Hello there, > > On my site I have a list of users, each of which can post status > updates on their profile. Each user can search for other users and > view their profiles too. > > The odd thing is, if I log in and out of each user and look at their > status, their posts are specific to them (which is what i want) > However...... If I search for a user and click to view their profile, > it seems to display the posts of the logged in user which is what i > dont want. > > Below is the show method which is what the profile page uses. > I have tried limiting it to 1 post for a user, and also tried to set > the initial param before the find to try and get around the issue. > Unfortunately these didn't work.. > > def show > username = params[:username] > @user = User.find_by_username(username) > if @user > @title = "Profile page of: #{username}" > @info = @user.info ||= Info.new > @posts = Post.find_by_user_id( session[:user_id], :order => > "created_at DESC") > respond_to do |format| > format.html > end > else > flash[:notice] = "No user #{username} found!" > redirect_to :action => "index" > end > end > Can anyone see why a: It displays the users status updates correctly > when i'm logged in as each user and b: why the posts seem to stay as > per the logged in user when i click on another user's profile?? > > Any suggestions, or ways round this appreciated. > > Thanks for reading. -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

