How to pass default Param info in a form (add a post to a specific category)
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:
@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'
(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| %>
<%= f.text_field :title %>
short description:<br />
<%= f.text_field :description %>
<%= text_field_tag 'tags', params[:tags] %>
<%= submit_tag %>
<% end %>
Thanks for any help!