small medium large xlarge

Generic-user-small
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.

Regards

Peter

Personproto_pragsmall
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: http://pragprog.wikidot.com/changes-to-rails

(hope this is new info for you)

cheers,

Calvin

Generic-user-small
09 Jun 2009, 15:42
Peter Shearan (2 posts)

Calvin

Thanks for the suggestion but I had already checked these.

Anybody else got any thoughts or ideas?

Regards

Peter

Generic-user-small
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 => @entity.id } do form %>

And in the controller this code

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

You must be logged in to comment