Hi, I am having troubles with a form_remote_tag. I have this form: <% form_remote_tag :url => { :action => ''create'', :controller => ''invitations'' } do %> <%= hidden_field_tag ''invite'', user.id %> <%= hidden_field_tag ''command'', ''invite_user'' %> <%= submit_tag(''Invite'') %> <% end %> That ends up if the a controllers function (after entering from create...): def invite_user(friend_to_invite) invited_user = User.find(friend_to_invite) current_user.request_friendship_with(invited_user) invitation = Invitation.new invitation.user_id = current_user.id invitation.status = 0 if invitation.save @pending_friends_by_me = current_user.pending_friends_by_me puts "@pending_friends_by_me" puts @pending_friends_by_me puts "/@pending_friends_by_me" render :update do |page| page[:sent_invitations].replace_html :partial => "sent_invitations" end return end end ------------ _sent_invitations is the partial that shows the contents of @pending_friends_by_me. So you press the button on the form and this partial is updated with the current invitations sent. THE PROBLEM Whe the partial is updated from the function above it still doesn''t contain the updated @pending_friends_by_me, the last invitation is not visible. It returns to the view but the contents are still the same. If I just refresh the page then the partial gets all the invitations. How to solve this? ------------- I went to the model and used the after_save callback, when that is called inspecting the invitations then all of them are already present. But didn''t have access to render functions there, and I don''t think I should actually call it from ther anyway. Any hints? Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
try a current_user.reload or current_user.pending_friends_by_me.reload in your controller after the save. maybe this helps. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
comopasta Gr
2009-Feb-12 07:52 UTC
Re: form_remote_tag comes back before saving really done?
Ha! current_user.pending_friends_by_me.reload Yeah that fixed it! Thanks MaD! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---