Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Working on my own rails app; having a hard time with create, new, and adding things to the database

Hi everyone,

I’m in the post-tracks, working on projects phase of my Rails learning, and I’m a bit stuck. I will say this is mostly because I’ve been cobbling together different code and seeing what sticks, and sometimes that means that what I made doesn’t work.

Right now I’ve got an app with a functional user database. I’m trying to connect my second database so that each user can add RSS feeds and they will tie in to the user (based on the shared user ID).

I was successful in adding a record through the console where the url is included. However, if I go to my feeds page and try to add a new feed, after the feed is added it looks like this:

feedspage

As you can see, the url is somehow “lost,” and if I check the record in the console, it has a feedurl of “nil.”

I am also having an issue where destroy just...doesn’t.

I realize that this is a pretty vague question, but I really am hoping that maybe someone could see what’s going on with my controller and tell me what I missed.

One other thing: like I said, I’m not quite sure what the deal is with my code and why it’s not working, partially because I’m cobbling code together from various sources. I might be missing something super obvious...and if so, please let me know.

The main project is here, and the feeds controller is here.

Thanks for looking. :grinning:

Jim

Edited to add: I just realized that destroy is not working because I didn't write the controller yet. Whoops.

1 Answer

I've had a look around your code. I'm learning myself, but I've built a couple of apps.

I can't see anything obvious. I think my first step would be to un-comment-out the "validates: :user_id, presence: true" line in your feed.rb model, then run your app, maybe create a feed, see if any errors are returned in the browser, look for errors in your server log, too.

Why do you have that line commented out? Maybe you have a good reason that I'm missing.

Also, which version of Rails are you using? I used Rails 4.2, and I haven't seen "validates" written with the colon, but maybe that's fine.

Hi Andrew--

Thanks for replying! A lot of the commented out code is there because, well, I didn't know if I needed it, so I commented it out to see. :-) It's not finished, that's for sure!

A recent commit includes some stuff that someone helped me fix.

Thanks!