I have an Article item that i’m linking another article to. When the
user hits the ‘add link’ button, i pass through a parameter called
“original_article_id”, which points to the current article:
#on my article’s ‘show’ page:
<%= link_to ‘Add a link’, :action => ‘new_link’, :original_article_id =>
@article.id %>
There’s no ‘new_link’ action, just a form page called new_link. On the
form, i can get the original_article_id no problem: i get the article
and display its title:
<% @orig_article = Article.find(:first, :conditions => [“id = ?”,
params[:original_article_id]]) %>
New link for "<%= @orig_article.title unless @orig_article == nil %>"
So far so good. However, when the form gets submitted, it calls my
‘create_link’ action, in the controller, and this can’t retrieve the
original_article_id: doing the exact same find as above gives me nil:
#in the controller this returns nil
@original_article = Article.find(:first, :conditions => [“id = ?”,
params[:original_article_id] ])
It’s as if when my form is submitted my parameter gets lost. Does
anyone know why this is happening? Is it something to do with the
params hash getting wiped before submitting the form details in it?
thanks in advance…