small medium large xlarge

18 May 2009, 12:41
Peter Shearan (2 posts)

I’ve worked thru the example in Chapter 21. Resource-Based Routing to create articles and associated comments.

The code for creating a new comment uses a form created using form_for:

<% form_for :comment, :url => comments_url, :article_id => @article_id do form %>

<— snip –>

<% end %>

In 2.3.2, this fails on creation as the before_filter :find_article looks for a params[:article_id] but cannot find it. The param should have been created by :article_id => @article_id in the form_for declaration.

I built the same simple system on 1.2.6 and it works just fine!!

I’ve looked at the API and on forums and this should work but I can’t get it to create any params in the form_for declaration. Is this a bug or has something changed in 2.3.2.



01 Jun 2009, 18:43
Calvin Stephens (7 posts)

I’m a beginner at Rails but if there is a change in 2.3.2, there is a wiki for Agile dev with Rails 3rd edition with documented changes at:

(hope this is new info for you)



09 Jun 2009, 15:42
Peter Shearan (2 posts)


Thanks for the suggestion but I had already checked these.

Anybody else got any thoughts or ideas?



02 Jul 2009, 04:49
Richard Day (1 post)

I am new to Rails and this probably breaks all sorts of standards but I got it to work by doing the following.

In the view I put the following code for the form_for declaration

<% form_for :entity, :url => { :action => :update_entity, :entity_id => } do form %>

And in the controller this code

@entity = Entity.find(params[:entity_id])

You must be logged in to comment