DEV Community

Discussion on: Here's what I struggled with today

Collapse
 
scottw profile image
Scott Watermasysk

I am not sure if you are just summarizing your day or asking for specific help.

If you want help to diagnose the issue, it would probably be a good idea to publish the code on Github. This way, someone could take a peak and provide some more relevant help.

Reading over your post, it sounds like your user is instance is not defined.

Also, I would watch out for code patterns like this:

<%= f.hidden_field :username, :value => @user.username %>

In theory, anyone viewing this could change the username to a different value.

Something like this:

post = Post.new(post_params)
post.username = @user.username
if post.save

Should meet your goals and protect you long term.

-Scott

Collapse
 
saral profile image
Saral Karki • Edited

Thanks, Scott for the tips. :)

With this write up, I think I was summarizing my day, but also was seeking help. However, I don't think I gave enough for others to diagnose the issue and help me out. Will definitely use Github next time around.

Cheers