How to move logic out of views and into controller in Rails
===

I am writing an [imageboard][1] in Ruby on Rails.

I have a form for creating new posts. In that form, there is logic to figure out whether the post was created from board#show or topic#show and act accordingly. It is:

      <% if @board != nil %>
        <%= f.hidden_field :board_id, :value => @board.id %>
      <% end %>
    
      <% if @topic != nil %>
        <%= f.hidden_field :topic_id, :value => @topic.id %>
      <% end %>

The form is rendered on board#show and topic#show with this piece of code:

	<%= render :partial => 'posts/form'%>

Should I move that logic to the controller? How would I go about doing that?


  [1]: http://en.wikipedia.org/wiki/Imageboard
