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.
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
Post a Comment