Go back to previous action

Hello all!
I have two views (list_1 and list_2) that show a list of users in two
different ways. In the views for these actions there is a link to edit a
specific user properties (edit_user). That works fine, except that when
I change the user I want to go back to the view that originated the
request and not to the default list (list_1).

Can anyone help me?

Best regards,
Hugo

I have a loop in which I cycle though a list of timesheet entries,
somewhat like:

@timesheet.each do |timesheet|

end

I would like to have “Up” and “Down” links in each row to reorder the
list. However, this is only allowed to happen for two entries with
the same date. So if there was only one entry for a particular date,
there wouldn’t be any links. It’s easy enough to get the previous
line’s date using an instance variable, but is there any easy way to
“read ahead” and get the date for the next record? I had to resort to
using javascript to populate the links when my site was based in PHP.

Thanks!!

Hugo wrote:

Hugo

I use two methods. One to drop a ‘cookie crumb’ in the session and one
to redirect to the cookie crumb. In the edit_user action, save the
referrer in the ‘cookie crumb’. In the update redirect to the saved
cookie crumb.

So in usage its as simple as:
def edit_user
drop_cookie_crumb
… do edit stuff
end

def update_user
… do update stuff
return_to_cookie_crumb
end


Jack C.
[email protected]

On 2/3/06, Dylan M. [email protected] wrote:

there wouldn’t be any links. It’s easy enough to get the previous
line’s date using an instance variable, but is there any easy way to
“read ahead” and get the date for the next record? I had to resort to
using javascript to populate the links when my site was based in PHP.

Thanks!!


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

each_with_index is your friend. Or, alternatively, you can add your
own iterator.

  • Rowan Rodrik

Hugo wrote:

Hello Jack. Thanks for your help.
I just have two questions:
IF a user is using a browser with tabs (like Firefox) and opens list_1
in one tab and list_2 in another and then clicks edit_user link in both
tabs what will happen? How can I distinguish the two requests so I can
send the user to the correct list action?

Try using ‘redirect_to :back’
I think this uses the browser window history.

_Kevin


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Hello Jack. Thanks for your help.
I just have two questions:
IF a user is using a browser with tabs (like Firefox) and opens list_1
in one tab and list_2 in another and then clicks edit_user link in both
tabs what will happen? How can I distinguish the two requests so I can
send the user to the correct list action?

Jack C. wrote:

Hugo wrote:

Hugo

I use two methods. One to drop a ‘cookie crumb’ in the session and one
to redirect to the cookie crumb. In the edit_user action, save the
referrer in the ‘cookie crumb’. In the update redirect to the saved
cookie crumb.

So in usage its as simple as:
def edit_user
drop_cookie_crumb
… do edit stuff
end

def update_user
… do update stuff
return_to_cookie_crumb
end


Jack C.
[email protected]