Auto Fill Data When Edit Post in Ruby on Rails -


hello i'm totally new ruby on rails, please friends, explain as u can. have create post , category mvc, added category:references in post model, working fine.

when i'm create post data publish category. when i'm editing post again, category data not filling, while when create post fill category in post article. please tell me how add code auto fill category when m editing post article. scrrenshot posts/new

thanks lot

/app/controllers/posts_controller.rb

@current_category = category.find(params[:id]) @categories = category.all 

/app/views/posts/edit.html.erb

<% @categories.each |category| %>   <%= category.id %> <br />   <% if category.id == @current_category.id %>     current   <% end %> <% end %> 

then can add select html , make current category selected


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -