This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/week-4-rail-controller-and-views-part-2
Instead of using Rails 2.3.11 as suggested in the course I am using the latest 4.2.1
I was getting the following error for my create method:
ActiveModel::ForbiddenAttributesError in CardsController#create
So I switched from this create method:
def create @deck = find_deck @card = @deck.cards.new(params[:card]) @card.save redirect_to @deck end
to this one and it worked:
def create @deck = find_deck @card = @deck.cards.new(cards_params) @card.save redirect_to @deck end private def cards_params params.require(:card).permit(:front, :back) end
I might be getting the following error because I’m using a newer version of rails but I’ve been doing exactly what’s on the video.
The error is:
NoMethodError in SessionsController#create
undefined method `’ for nil:NilClass
and it points to this line in the create method:
user = User.find_by_email(params[:session][:email])
Anyone knows how I could fix this?
I had that error also. I believe that you should use the same email that you used for creating a new user earlier.