strong-parameters

Strong Parameters - Can't Access the Deeply-Nested Attributes

僤鯓⒐⒋嵵緔 提交于 2019-12-24 05:05:17
问题 One StackOverflow question has asked what I need, but the self-answer didn't help me know what to do next. The scenario presented in that question (whitelisting deeply nested strong parameters in rails) is pretty much what I've got going on, but I'll post an abbreviation of mine (still very long) and hope someone--maybe even the Dave of the post--can help (I don't have enough reputation to comment and ask him). There are few links about nested strong parameters I haven't read, and I've dealt

Strong Parameters - Can't Access the Deeply-Nested Attributes

老子叫甜甜 提交于 2019-12-24 05:05:03
问题 One StackOverflow question has asked what I need, but the self-answer didn't help me know what to do next. The scenario presented in that question (whitelisting deeply nested strong parameters in rails) is pretty much what I've got going on, but I'll post an abbreviation of mine (still very long) and hope someone--maybe even the Dave of the post--can help (I don't have enough reputation to comment and ask him). There are few links about nested strong parameters I haven't read, and I've dealt

Rails 4.1 Nested Attributes and Fields For Getting Unpermitted Parameters and Not Saving

笑着哭i 提交于 2019-12-24 00:55:44
问题 Research: Rails 4.0 beta, fields_for not accepting pluralized model_name in one-to-many association, Rails 4 Nested Attributes with fields_for Don't Save to Database First, let's get the most common problem out of the way: incorrectly named attributes parameters for strong parameters. Mine is correctly plural. class AdultsController < ApplicationController ... def update authorize @user respond_to do |format| if @user.update_attributes(user_params) format.html { redirect_to unit_adult_path(

Rails 4 Nested Attributes with fields_for Don't Save to Database

不羁的心 提交于 2019-12-24 00:04:22
问题 I want to create records on two different tables (venue and parking) via one form using accepts_nested_attributes_for. I want a user to be able to create a new venue, and also specify the parking options available to that venue via checkboxes. When I submit the form, the record for the containing model (venue) is created, but nothing happens with the nested model (parking). When I check the response from the server, I see that I'm encountering "Unpermitted parameters: parking_attributes,"

Rails 5 strong params with an Array within check boxes values

我与影子孤独终老i 提交于 2019-12-23 17:33:00
问题 Given these params: "product"=><ActionController::Parameters {"id"=>"", "category_ids"=><ActionController::Parameters {"2"=>"1", "3"=>"1", "4"=>"1"} , "name"=>"...", "description"=>"a good prod", "size"=>"2x3m", "price"=>"23$", "url_video"=>"http://...", "remarks"=>"bla"} I want to cath category_ids params {"2"=>"1", "3"=>"1", "4"=>"1"} with the correct permit and require sintax, than I don't know: when execute params.require(:product).permit(:name, :size,..., category_ids: [] ) the result is

wrong number of arguments (2 for 1) Rails 4. Maybe strong_params issue

房东的猫 提交于 2019-12-23 12:46:55
问题 I'm using Rails 4 with Devise, Cancan and Rollify. I've got an index of users with a modal to change the role. However when I try to update the role I get the following error: "wrong number of arguments (2 for 1)" The error occurs in line 16 of my User controller code: 13 def update 14 authorize! :update, @user, message: 'Not authorized as an administrator.' 15 @user = User.find(params[:id]) 16 if @user.update_attributes(params[:user], as: :admin) 17 redirect_to users_path, notice: "User

JSONAPI strong params with Rails and Ember

拜拜、爱过 提交于 2019-12-23 12:36:20
问题 I'm using Ember with ember-data and a rails api. I had a createRecord() and save() for the record that was working fine. The payload in the network tab for the post request to create the record in rails looks like: {data: {attributes: { foo: 'bar' } } . In the rails controller, I have strong params like so: params.require(:data).require(:attributes).permit(:foo) , which was working fine for a little while. Now when I send the request rails says that param is missing or the value is empty:

How to make an optional strong parameters key yet still filter params nested in it?

£可爱£侵袭症+ 提交于 2019-12-23 06:48:36
问题 I have this in my controller: params.require(:item).permit! Let's assume this rspec spec: put :update, id: @item.id, item: { name: "new name" } It works as expected, no error. However, if I use this: put :update, id: @item.id, item: nil I get ActionController::ParameterMissing which I don't want to get. It has to do with controller macros that I use for other actions and through which I cannot control the params being sent (the macros checks for user credentials, so I don't really care about

Trouble with uploading file after upgrating rails from 3.2 to 4

萝らか妹 提交于 2019-12-23 04:03:14
问题 Uploading files in my gallery worked fine with Rails 3, but after upgrate I get exeption wrong argument type ActionDispatch::Http::UploadedFile (expected String) in this line @reel.update_attributes(reels_params) . I don't use any gem for handle file uploading, because I need specific processing and store my files in db. After upgraded to rails 4, I added only 1 method to working with strong params in controller reels_params . Controller: class Admin::ReelsController < AdminController before

Strong parameters: Unpermitted parameters: tags in has_many_through relation

十年热恋 提交于 2019-12-23 02:59:05
问题 I have a few models/controllers: event.rb: class Event < ActiveRecord::Base belongs_to :category belongs_to :user has_many :event_tags has_many :tags, through: :event_tags has_many :event_skills has_many :skills, through: :event_skills tag.rb class Tag < ActiveRecord::Base has_many :events, through: :event_tags has_many :event_tags end event_tag.rb class EventTag < ActiveRecord::Base belongs_to :event belongs_to :tag end user.rb: class User < ActiveRecord::Base has_many :events # organized