spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

new using rails 4 - ActiveModel::ForbiddenAttributesError


In create action change params[:video] to video_params:

 def create
    if @person = Video.create(video_params)
      flash.now[:success] = "Thanks for suggest
this video"
      redirect_to root_path
    else
      flash.now[:error] = "Impossible to add this
suggestion"
      redirect_to new_frontend_video_path
    end
  end

You should permit params, instead Rails raise ActiveModel::ForbiddenAttributesError.


Categories : Ruby On Rails

Related to : new using rails 4 - ActiveModel::ForbiddenAttributesError
Why ActiveModel::ForbiddenAttributesError error?
Just change the where(condition) to: where(provider: auth.provider, uid: auth.uid) The 1st approach fails because of the method #permitted? which AR calls (if defined) to sanitize the attributes. > h = auth.slice(:provider, :uid) > h.class => OmniAuth::AuthHash < Hashie::Mash > h.permmitted? > false However, a simple Hash will not have #permitted? defined, thus it will just

Categories : Ruby On Rails
How do you Skip an Object in an ActiveModel Serializer Array?
That looks correct, try returning an array instead of a hash when you dont want any keys. Also, I don't think calling super is necessary b/c the filter takes in the keys. Also, I don't think defining an attributes method is necessary.

Categories : Json
ActiveModel Serializer sending all records instead of specified limited amount
Check out the guides on associations: By default, serializers simply look up the association on the original object. You can customize this behavior by implementing a method with the name of the association and returning a different Array. So, each model gets serialized according to its serializer. Your organization models were being put through your OrganizationSerializer, which had has_man

Categories : Ruby On Rails
Rails, separate search function within rails form
Add a hidden array field in the form called products. outside the form handle products search,selection and update of that hidden field via Ajax call. Check this link, Its a similar but simpler example cause he just want to add addresses dynamically while you still have the products searching handled via Ajax first. Please note that the only part you need from his solution is how he updates the f

Categories : Ruby On Rails
ActiveRecord saving: differences in Rails 3.2.19 and Rails 4.2.0
This is related with Strong Parameters which are enabled by default in the 4.x version. Taking the example from the documentation: class PeopleController < ActionController::Base # This will raise an ActiveModel::ForbiddenAttributes exception because it's using mass assignment # without an explicit permit step. def create Person.create(params[:person]) end # This will pass with

Categories : Ruby On Rails
Recently Add
Groups and Users has many oder has many through?
Rails format specifier differences
Capistrano can not create symlinks: file exist
Admin can't delete users. Ruby on Rails 3 - Michael Hartl
Don't show user name who create post
Using Wicked with Devise (2 step signup process)
RubyOnRails Rake test failures
Rails session start event handler
Why ActiveModel::ForbiddenAttributesError error?
How can i track the issue in production RAILS
Cannot install spree gem - ERROR: invalid gem: package is corrupt
Why are the nested resources for Devise authentication not working?
Rails Devise - how to open access to the site root
Rails: respond_with the same template for two methods
rails with postgresl database "role postgres does not exist"
Instance variable in Rails helper not set
Monkey patch rails 3.2 rake task
Rails_admin: Should I have admin_user or user with admin role to manage users and admin panel
undefined method `attachments' for nil:NilClass
Memory usage increase with Ruby 2.1 versus Ruby 2.0 or 1.9
Can a Rails app be deployed without using Heroku Toolbelt? If so, how?
Enable random access to collection with MongoDB
libmysqlclient-dev installation fails
undefined method `name' for nil:NilClass. Can't find @followed.name but @followed is set
Allowing an arbitrary domain and subdomain in session_store.rb
Pushmeup Gem - Can't send push notifications in Active Admin model
Rails console does not start
GitHub Import: Could not locate Gemfile
AWS::S3::PermanentRedirect in SongsController#index "The bucket you are attempting to access must be addressed using the specified endpoint"
automatically create ActiveRecord parent for association
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.