Dangerousattributeerror in Omniauth Railscast Tutorial: Create Is Defined by Activerecord

DangerousAttributeError in OmniAuth create is defined by ActiveRecord

it's telling you to create a migration to remove the problematic fields and then run the migration

to make it clearer:

run this command:

rails g migration drop_silly_controller_attributes

that command will create a file in /db/migratie/ with the timestamp and that name, something like:

2013121212312312_drop_silly_controller_attributes.rb

open that file and modify it to look like this:

class DropSillyControllerAttributes < ActiveRecord::Migration
def change
remove_column :authentications, :index
remove_column :authentications, :create
remove_column :authentications, :destroy
end
end

then you can run the migration doing:

rake db:migrate

it's confusing because the if you generate the migration with "remove_silly_authentication_fields_which_should_not_be_there" the class should be RemoveSillyAuthenticationFieldsWhichShouldNotBeThere, but then it says "DropSillyControllerAttributes", so you should generate the migration with drop_silly_controller_attributes to make it consistence

DangerousAttributeError in OmniAuth Railscast Tutorial: create is defined by ActiveRecord

Activerecord is warning you that some of your database attribute names (create etc.) clash with the names of instance methods provided by activerecord/ruby.

Since rails would otherwise create instance methods of those names to access attributes, such a clash used to cause really weird things to happen. Thus active record raises an exception to warn you that this is happening

Omniauth not working

In your User.rb line #14

instead of omniauth['user_info']['email'] it should be omniauth['info']['email']

For nifty generators you should have

gem "nifty-generators", group: :development

in you Gemfile

Try rails g scaffold --help to see the available options for scaffold generator

You may also have a look at this amazing rails-cast too generators-in-rails-3

Rails Omniauth - NoMethodError in AuthenticationsController#create

I've figured out the problem. Since I'm not logged in to the system, current_user is null, therefore it gaves an error.

+

now I wrote all of my experiences and made a tutorial with the source code, that provides multiple authentication with Facebook and Twitter:
http://www.orhancanceylan.com/rails-twitter-and-facebook-authentications-with-omniauth-and-devise/

OmniAuth for facebook

just add to you omniauth.rb credentials for facebook

Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, 'CONSUMER_KEY', 'CONSUMER_SECRET'
end

In you session or authentication action(where you deal with twitter login) add extra logic for facebook.

Hartl Tutorial + Omniauth: Log In not Logging In

This same error gave me a headache once. Check if the email you use for facebook is already in your database. If it's there then delete it and it should work.



Related Topics



Leave a reply



Submit