ga-dc / wdi5-project4

3 stars 0 forks source link

heroku error #122

Closed janicemin closed 9 years ago

janicemin commented 9 years ago

error message when i try to heroku run rake db:seed after migrating...

i dropped my database and created, migrated and seeded again in the terminal...and the seeded zipcodes are showing up in my database.

ActiveRecord::UnknownAttributeError: unknown attribute 'zipcode' for Profile.
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/attribute_assignment.rb:59:in `rescue in _assign_attribute'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/attribute_assignment.rb:54:in `_assign_attribute'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/attribute_assignment.rb:41:in `block in assign_attributes'
janicemin commented 9 years ago

i'm also running into an error that i hadn't previously where if i created my profile, the zipcode doesn't show for some reason and my ajax request seems to not work because of that....it had earlier...

RobertAKARobin commented 9 years ago

Just to be sure: the Profile model has a field called "zipcode", db:migrate is correctly adding the zipcode column to the Profile table, and db:seed is correctly filling in the zipcode column with values?

RobertAKARobin commented 9 years ago

If you're running into AJAX problems, please open up the console in Chrome and let us know the error you're getting! Also, pushing to Github again would be great so I can take a look at your code.

janicemin commented 9 years ago

i pushed it!

janicemin commented 9 years ago

i'm not getting an error on the console in chrome...the meetup activity groups that i had been previously seeing just aren't showing. it had been working earlier and i'm not sure why i'm now getting errors about zipcodes. my ajax request is dependent on the profile zipcode.

janicemin commented 9 years ago

in my profile table, the seeded zipcode shows up fine

RobertAKARobin commented 9 years ago

Seems to be working for me!

screen shot 2015-06-04 at 8 58 07 pm

janicemin commented 9 years ago

would you be able to take a look at my ajax request? i'm not sure why when i enter a different zipcode/update a zipcode, the meetup groups aren't changing accordingly?

i thought this line of code would make it so that it reads differently each time a new user logs in or i update mine. url: 'https://api.meetup.com/find/groups?photo-host=public&zip=' + %=@profile.zipcode% + '&page=20&country=usa&sig_id=188185019&sig=d9f44a2c374e46c96fe2447861de68aa7750ec29'

janicemin commented 9 years ago

i had hardcoded a zipcode earlier but then changed it to this and so assumed it was working fine until the heroku issues popped up...

janicemin commented 9 years ago

screen shot 2015-06-04 at 9 17 05 pm the zipcode won't even show on the show page for some reason when i made a new user? i don't think i was running into this problem earlier?

RobertAKARobin commented 9 years ago

Which page is the AJAX error on?

RobertAKARobin commented 9 years ago

Something else to consider: if zip codes aren't essential to your app, just remove them altogether!

janicemin commented 9 years ago

they are because the user is supposed to find activities in the area to preoccupy themselves, haha.

janicemin commented 9 years ago

sorry in the show.html.erb file under profiles

RobertAKARobin commented 9 years ago

Gotcha

RobertAKARobin commented 9 years ago

Where is the AJAX request in this? What is it supposed to do?

RobertAKARobin commented 9 years ago

Gaahh.

RobertAKARobin commented 9 years ago

Github thinks you're writing HTML if you don't do this:

Your code
```
janicemin commented 9 years ago
$.ajax({
           type: 'GET',
           dataType: 'jsonp',
           jsonp: 'callback',
           url: 'https://api.meetup.com/find/groups?photo-host=public&zip=' + <%=@profile.zipcode%> + '&page=20&country=usa&sig_id=188185019&sig=d9f44a2c374e46c96fe2447861de68aa7750ec29'
               }).done(function(response){
                    for (i = 0; i < response["data"].length; i++){
                            console.log(response["data"][i])
                            console.log(response["data"][i]["name"])
                            $(".name").append("<a href='" + response["data"][i]["link"] + "'>"  + response["data"][i]["name"] + "</a>")

                    }
               })

</script>

</div>
RobertAKARobin commented 9 years ago

Your AJAX request is working! Try putting console.dir(response); right after the .done line. You'll see that you're getting back an error message from the API. "Authentication credentials are required"

RobertAKARobin commented 9 years ago

The problem with zip codes is in your profiles controller:

    private
        def profile_params
            params.require(:profile).permit(:name, :age, :location, :phone_number, :email)
        end

See anything missing?

janicemin commented 9 years ago

? :p

RobertAKARobin commented 9 years ago

Zipcode is missing. What tipped me off was seeing this in the server log: Unpermitted parameter: zipcode

janicemin commented 9 years ago

ohhhhh!

janicemin commented 9 years ago

just a follow-up question about the authentication...does this mean that i have to do something like oauth for twitter/fb but for meetup.com in order for a new user to find groups in their area?

RobertAKARobin commented 9 years ago

I don't know anything about their API. Maybe? You'll need to check their API docs.

janicemin commented 9 years ago

copy that. thanks!