Hi, So I''ve built a page controller that lists pages, with a link to edit the page. When you click the edit button, the edit view lists the page title and the associated articles with that page, using: (in the controller) @articles_pages, @articles = paginate(:articles, :conditions=> [''page_id = ?'', @page]) Article is a separate model with a belongs_to :page in its model and a foreign key page_id. The trouble comes when the user clicks on the Edit Article link. It opens up the edit view and displays the article, with the following displayed: <h1>Editing article</h1> <% form_tag :action => ''update'', :id => @article do %> <%= render :partial => ''article_form'' %> <%= submit_tag ''Edit'' %> <% end %> <%= link_to ''Show'', :action => ''show'', :id => @article %> | <%= link_to ''Back'', :action => ''edit_page'', :id=>@page.id %> The last line is the problem. I need some way for the application to remember which page is associated with the article and return the user to editing the page from the edit article form. I''m not sure if I should pass a param here or store the id in flash? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nathan Esquenazi
2008-Mar-13 20:06 UTC
Re: How do you get flash to store something other than a str
Flash is a mechanism for displaying text onto the view. If you want to "store" other types of data, you should use either a cookie or the session. -- 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Mar-13 20:44 UTC
Re: How do you get flash to store something other than a str
On 13 Mar 2008, at 20:06, Nathan Esquenazi wrote:> > Flash is a mechanism for displaying text onto the view. If you want to > "store" other types of data, you should use either a cookie or the > session.Actually the flash isn''t magic at all. It''s just a hash which is auomatically emptied at the right time (and it is actually stored in the session). It''s commonly used for passing strings around, but I don''t see why you couldn''t stick in it anything you could stick in the session. Fred> -- > 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 > -~----------~----~----~----~------~----~------~--~--- >
Thanks Fred and Nathan. I guess perhaps I asked the wrong question--the real question here is how do you retrieve the page that is associated with the array of articles again when the user is done editing? I''ve tried this: I''ve defined a page_id method in the article model. def self.page_id Article.page_id end Then in the edit action in the articles controller, @page=Page.find(:conditions=>[''id = ?'', Article.page_id]) Then in the edit view: <%= link_to ''Back'', :action => ''edit'', :controller=>''page'', :id=>@page %> I don''t think I''ve done this right. Now I''m getting stack level too deep error. Ron P.S. Fred--you studied mathematics? That''s really awesome--I''m studying grad stat right now. On Mar 13, 1:44 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 13 Mar 2008, at 20:06, Nathan Esquenazi wrote: > > > > > Flash is a mechanism for displaying text onto the view. If you want to > > "store" other types of data, you should use either a cookie or the > > session. > > Actually the flash isn''t magic at all. It''s just a hash which is > auomatically emptied at the right time (and it is actually stored in > the session). > It''s commonly used for passing strings around, but I don''t see why you > couldn''t stick in it anything you could stick in the session. > > Fred > > > -- > > Posted viahttp://www.ruby-forum.com/. > > > > > > > smime.p7s > 5KDownload--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---