DEV Community

Here's what I struggled with today

Saral Karki on February 04, 2019

During my run this evening, I happened to listen to a podcast on codeNewbie(I have been doing this a lot lately). The guest on this episode was the...
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

Collapse
 
jsingh profile image
Jitendra Singh

Where is project link?

Collapse
 
saral profile image
Saral Karki

Here's my project threeirblog.herokuapp.com. Although, I am still working on it. I will upload my post of Github too so that I can get better solution for my issue.