RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: chloereimer
I forgot to include @entry.save, which became problematic in Part 2... modified create method below.
def create @entry = Entry.new( entry_params ) @entry.save respond_with @entry end
Since the given EntriesController doesn't use strong parameters, I'd get 500 errors when attempting to create/update entries in the console. I revised EntriesController to the below version, which hasn't thrown any problems my way so far.
class EntriesController < ApplicationController respond_to :json def index respond_with Entry.all end def show respond_with Entry.find(params[:id]) end def create @entry = Entry.new( entry_params ) respond_with @entry end def update @entry = Entry.find(params[:id]) respond_with @entry.update( entry_params ) end def destroy respond_with Entry.destroy(params[:id]) end private def entry_params params.require(:entry).permit(:name,:winner) end end
I forgot to include @entry.save, which became problematic in Part 2... modified create method below.
Since the given EntriesController doesn't use strong parameters, I'd get 500 errors when attempting to create/update entries in the console. I revised EntriesController to the below version, which hasn't thrown any problems my way so far.