strong-parameters

Rails 4 - Strong Parameters - Nested Objects

泄露秘密 提交于 2019-11-26 10:21:42
I've got a pretty simple question. But haven't found a solution so far. So here's the JSON string I send to the server: { "name" : "abc", "groundtruth" : { "type" : "Point", "coordinates" : [ 2.4, 6 ] } } Using the new permit method, I've got: params.require(:measurement).permit(:name, :groundtruth) This throws no errors, but the created database entry contains null instead of the groundtruth value. If I just set: params.require(:measurement).permit! Everything get's saved as expected, but of course, this kills the security provided by strong parameters. I've found solutions, how to permit

Rails 4.0 with Devise. Nested attributes Unpermited parameters

筅森魡賤 提交于 2019-11-26 09:29:14
问题 I am working on a web-app using Devise and Rails 4. I have a User model which I have extended with 2 extra form fields such that when a user signs up he can also submit his first/last names. (based on http://blog.12spokes.com/web-design-development/adding-custom-fields-to-your-devise-user-model-in-rails-4/). I now want to add a Institution model. This model has_many :users, and a user belongs_to :institution. I want to be able to register the institution\'s name on the same form I register

How to specify devise_parameter_sanitizer for edit action?

﹥>﹥吖頭↗ 提交于 2019-11-26 09:28:33
问题 I\'ve added Devise to my Rails 4 application, and successfully added username etc. to my User model. Furthermore, I\'m able to store those fields using the lazy way™, i.e. class ApplicationController < ActionController::Base before_filter :configure_permitted_parameters, if: :devise_controller? protected def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :password_confirmation, :firstname, :middlename, :lastname) } end end However, I

how to permit an array with strong parameters

纵然是瞬间 提交于 2019-11-26 00:17:35
问题 I have a functioning Rails 3 app that uses has_many :through associations which is not, as I remake it as a Rails 4 app, letting me save ids from the associated model in the Rails 4 version. These are the three relevant models are the same for the two versions. Categorization.rb class Categorization < ActiveRecord::Base belongs_to :question belongs_to :category end Question.rb has_many :categorizations has_many :categories, through: :categorizations Category.rb has_many :categorizations has