1

Tune gem Sorcery through article: github.com/NoamB/sorcery/wiki/External.

I have done so, the user after login can create a recording and attach it to an image that is downloaded to the S3 from Amazon AWS. But after setting up I can log in, but I can not upload the image. In terminal writes an error:

Can't mass-assign protected attributes for Card: review_date, original_text, translated_text, picture

Screenshot: http://monosnap.com/image/OyzrIct0G3uchY3XIUwyJEXxwUrcGU

In the settings of the controller's I use strong_parameters:

private
def card_params
  params.require(:card).permit(:review_date, :original_text, :translated_text, :user_id, :picture, :remove_picture)
end

Help me! How to use strong_parameters the code?

P.S. Sure, I have written and the controller: https://gist.github.com/windsochi/86ab6f541445896e65f0. I can not figure out how to get rid attr_accessible of and add strong_parameters?

Yuri Malov
  • 1,197
  • 8
  • 11

1 Answers1

1

In rails 4, make sure you use the card_params in your new and create actions:

def new
  @card = Card.new(card_params)
end

def create
  @card = Card.new(card_params)
end

private
  def card_params
    params.require(:card).permit(:review_date, :original_text, :translated_text, :user_id, :picture, :remove_picture)
  end

If you are in rails 3, take a look at https://github.com/rails/strong_parameters

gabrielhilal
  • 10,660
  • 6
  • 54
  • 81