Question

Using Active Scaffold on devise resource, error appeared after use of devise-invitatible

NameError in Admin/users#index

Showing /home/user/.rvm/gems/ruby-1.9.3-p286/gems/active_scaffold-3.2.16/frontends/default/views/_list_record_columns.html.erb where line #6 raised:

uninitialized constant User::InvitedBy

Extracted source (around line #6):

3:   <% column_value = authorized ? get_column_value(record, column) : active_scaffold_config.list.empty_field_text -%>
4: 
5:   <%= content_tag :td, column_attributes(column, record).merge(:class => column_class(column, column_value, record)) do %>
6:     <%= authorized ? render_list_column(column_value, column, record) : column_value %>
7:   <% end %>
8: <% end -%>
Was it helpful?

Solution

ActiveScaffold 3.2.x doesn't support links for polymorphic associations, you can call clear_link in invited_by column conf.columns[:invited_by].clear_link

I have disabled those links in rails-3.2 branch, but it will be in 3.2.18. Also you can use gem from git (gem 'active_scaffold', :git => 'git://github.com/activescaffold/active_scaffold) to use master branch which supports links for polymorphic associations.

OTHER TIPS

Adding some cross-linking that might help someone: Via this Github Issue: https://github.com/scambra/devise_invitable/issues/247

You can put:

filter :email #fixes uninitialized constant User::InvitedBy

in app/admin/user.rb

(I hope this is acceptable and will help someone)

Edit: I also was using devise_invitable, which was removed or never properly migrated:

def change
  add_column :users, :invitation_token, :string
  add_column :users, :invitation_created_at, :datetime
  add_column :users, :invitation_sent_at, :datetime
  add_column :users, :invitation_accepted_at, :datetime
  add_column :users, :invitation_limit, :integer
  add_column :users, :invited_by_id, :integer
  add_column :users, :invited_by_type, :string
  add_index :users, :invitation_token, :unique => true
end

# Allow null encrypted_password
change_column :users, :encrypted_password, :string, :null => true
# Allow null password_salt (add it if you are using Devise's encryptable module)
change_column :users, :password_salt, :string, :null => true

via: https://github.com/scambra/devise_invitable

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