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.
D3760253015655d7441a4206c762934d?d=identicon&s=25 Hugo (Guest)
on 2006-02-03 21: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
D9d1b31a337f46ac5e4dd56b55404f58?d=identicon&s=25 Dylan Markow (Guest)
on 2006-02-03 21: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!!
89441a6c74647d292f5cc951eae24cfa?d=identicon&s=25 Jack Christensen (Guest)
on 2006-02-03 22: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 Christensen
jackc@hylesanderson.com
41165a7e7126d616a0ae0762e00718e2?d=identicon&s=25 BigSmoke (Guest)
on 2006-02-04 17:35
(Received via mailing list)
On 2/3/06, Dylan Markow <dylan@dylanmarkow.com> 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
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails

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

  - Rowan Rodrik
D3760253015655d7441a4206c762934d?d=identicon&s=25 Hugo (Guest)
on 2006-02-05 12: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 Christensen 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 Christensen
> jackc@hylesanderson.com
C8a634a01a2c4508360874bff7fb1a7f?d=identicon&s=25 Kevin Olbrich (olbrich)
on 2006-02-05 14: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
89441a6c74647d292f5cc951eae24cfa?d=identicon&s=25 Jack Christensen (Guest)
on 2006-02-06 15:11
(Received via mailing list)
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
This topic is locked and can not be replied to.