Forum: Ruby on Rails Go back to previous action

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Hugo (Guest)
on 2006-02-03 22:30
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
Dylan M. (Guest)
on 2006-02-03 22:37
(Received via mailing list)
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!!
Jack C. (Guest)
on 2006-02-03 23:30
(Received via mailing list)
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.
removed_email_address@domain.invalid
BigSmoke (Guest)
on 2006-02-04 18:35
(Received via mailing list)
On 2/3/06, Dylan M. <removed_email_address@domain.invalid> 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
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails

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

  - Rowan Rodrik
Hugo (Guest)
on 2006-02-05 13:23
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.
> removed_email_address@domain.invalid
Kevin O. (Guest)
on 2006-02-05 15:45
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
Jack C. (Guest)
on 2006-02-06 16:11
(Received via mailing list)
_______________________________________________
Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails
This topic is locked and can not be replied to.