Hi guys, I want to save the current article id, but I don''t know how. someone have an example? Ex. I click on "show article", after that I click "edit article". When the editing is finished I want to click "back" and loading the show page with the previous article. -- 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 -~----------~----~----~----~------~----~------~--~---
Hey, Depending on your code, you should be able to just do @article.id in your view to access the current article''s id. For a route you can even drop the .id: <%= link_to ''Edit this article'', :action => ''edit'', :id => @article %> and if you''re using map.resources, it''s even shorter: <%= link_to ''Edit this article'', edit_article_path(@article) %> Hope that helps, Steve --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I don''t want to access to the current article.id but save it in the class and use it when I need to go back at the last article showed. I don''t know where i can store it, in the application.rb or in the articles_controller.rb, and how store it! 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 -~----------~----~----~----~------~----~------~--~---
I tried this:
-in application.rb
def current_article
if @current_article
return @current_article
else @params[:id]
return @current_article = @params[:id]
end
end
-in articles_controller.rb
def show
@article = Article.find(current_article)
end
It works if i try <%= link_to ''show'', :action =>
''show'', :id => article
%>
but if I try <%= link_to ''show'', :action =>
''show'', :id =>
@current_article %>
it doesn''t work.
What is wrong? 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
-~----------~----~----~----~------~----~------~--~---