Reply to topic
fulvio


Joined: 27 Dec 2006
Posts: 5
Reply with quote
In regards to the previous topic. I tried making the following change with no luck.

Code:
<%= render :partial => 'category', :locals => { :category => post.category } %>


Not sure what I'm doing wrong here. Confused
bushawa


Joined: 29 Apr 2008
Posts: 1
Reply with quote
In regards to not having your categories selected when editing a post.

Change your unless code block to the following in posts/edit.rhtml

Code:
<% unless @categories.empty? %>
      <% @selected = @post.categories.collect { |c| c.category_id.to_i } %>
      <select name="post[category_ids][]" multiple="multiple">
           <%= options_from_collection_for_select(@categories, :id, :title, @selected) %><br/><br/>
      </select>
   <% end %>


Now go back to list, refresh, click edit and it should now highlight all categories you have selected for that post.
Ruby on Rails tutorial - part 3
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 2 of 2  

  
  
 Reply to topic