ruby - Basic dashboard to manage posts in rails -


I have a blog that plans for authentication and where users can create posts, I have created an original dashboard Where users will be able to manage their posts

This is my dashboard controller

  before_action: authenticate_user! DF Index @Posts = Post.Fund (All :: Terms => ["user_id =?", @current_user])   

This is my dashboard view

  & lt;% @ posts.each do | Posted in | & Gt%; & Lt;% = post.content% & gt; & Lt;% end% & gt;   

This is my user model

  is_im: post   

and my post model

  related_to: user   

this is my schema. RB

  create_table "posts", force: true do | T | t.text "content" t.integer "user_id" t.datetime "created_at" t.datetime "updated_at" end   

But when I go to the dashboard I can not find any Post and when I can change my dashboard controller to

  def index @ postsall = post.all end   

I'am get all the posts To do so someone can say where is my fault.

find (: all, : Terms = & gt; []) was demoted in Rail 3.2. Instead, try:

  def index @ posts = post.where (: user_id = & gt; current_user) expiration   

Also, make sure In the method that you are adding user_id to your controller:

  def @ post = post.New (post_most) @ post.user_id = current_user empty code ends here    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -