uschtwill / rails_rss_aggregator

MIT License
3 stars 1 forks source link

Bug: manipulate (database) model(s) to allow users to bookmark entries #3

Open uschtwill opened 9 years ago

uschtwill commented 9 years ago

Implemented association, now working on the corresponding views, then API.

uschtwill commented 9 years ago

@alvinkatojr

Here we go. You said I should use a button. But I didn't get if that is a requirement or just a nice to have. From my understanding this should be an acceptable way of doing it, no? Even if it is not best practice or the most beautiful way to do it. Correct me, if I am wrong. Why is this failing?

The route:

  post 'users/:id/entries/:id' => 'users#add_entry_to_bookmarks', as => :add_to_bookmarks

The part in the view:

p
      =entry.content
      =link_to 'Add to your Bookmarks', "/users/#{current_user.id}/entries/#{entry.id}", :method => :post

The method in the controller:

  def add_entry_to_bookmarks
    @entry = Entry.find(params[:id])
    @user = User.find(params[:id])
    add_entry_to_bookmarks!(@user, @entry)
    redirect_to user_entries_path 
  end

The method in the model:

def add_entry_to_bookmarks!(user, entry)
    user.entries << entry
  end

The error screen I'm getting:

Oh and this error already pops up when just loading the root. screen shot 2015-03-10 at 15 27 07

uschtwill commented 9 years ago

@alvinkatojr High Prio!

alvinkatojr commented 9 years ago

Can't seem to get a hand on this one. Will need to run the code locally and see.

uschtwill commented 9 years ago

@alvinkatojr For the emergency, pull the newest changes. The version you cloned earlier was a bit messed up. The error does persist though.