Hi.

Regarding the Lenz Book:

Let's say you have categories and stories.

You have 3 categories: Music, Movies, and Books.

Let's say you select the Music category. Now, you would like to post a story link inside the Music category.

If you want to add a new story to a specific category, what code must you add to your story controller and story view template?

I have searched and couldn't find much help. It must have something to do with params.

My story controller contains:

def new
@story = Story.new(params[:story])
@story.user = @session['user']

if request.post? and @story.save

@story.tag_with params[:tags] if params[:tags]

flash['notice'] = 'your story has been accepted'
redirect_to :action => 'index'
end

(I don't know if I must add filters to the controller to make sure that the specific category id is passed on in the form. )

My story view is something like:

<% form_for :story do |f| %>
<p>
title:<br />
<%= f.text_field :title %>
</p>
<p>
short description:<br />
<%= f.text_field :description %>

</p>
<p>
Tags:<br />
<%= text_field_tag 'tags', params[:tags] %>
</p>

<%= submit_tag %>
</p>
<% end %>


Thanks for any help!