Question

Please see this page, as I have the same problem: DangerousAttributeError in OmniAuth Railscast Tutorial: create is defined by ActiveRecord

However being fairly new to rails, I am not quite sure as to how to remove the fields they speak of from the database. In other-words, there is no step-by-step concise way described anywhere in that post.

The below post is in fact a proper solution, but it is unclear as to what he was referring to when he wrote: "rails g migration remove_silly_authentication_fields_which_should_not_be_there" Not sure what "silly_authentication_fields_which_should_not_be_there" is exactly.

Here is the post I am referring to:

So just to finish the question off you will need to create a migration using this command:

rails g migration remove_silly_authentication_fields_which_should_not_be_there

Which looks something like this:

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

And run it using the usual:

rake db:migration

Or alternatively you should be able to run:

rake db:rollback

To roll back the changes just made to the database and:

rails d scaffold authentication

To remove all the files, then run:

rails g scaffold authentication user_id:integer provider:string uid:string

And do the other stuff manually

I did exactly the same thing myself by the way.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top