Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Associating current_user id to imported contacts list

Okey, based on your given information you can do the following to add the current_user_id to your contact.

In your ContactImportController


  def create
    @contact_import =
    @contact_import.user_id =
      redirect_to contacts_path, notice: "Imported
contacts successfully."
      render :new


  def contact_params


In your contact_import.rb file

 def load_imported_contacts
   spreadsheet = open_spreadsheet
   header = spreadsheet.row(1)
  (2..spreadsheet.last_row).map do |i|
  row = Hash[[header,
  contact = Contact.find_by_id(row["id"]) ||
  contact.attributes =
row.to_hash.slice('first_name', 'last_name',
'mobile', 'email', 'info')
  contact.user_id = self.user_id # this should


As you didn't mention where the Contact#load_imported_contacts either called in any before_save or before validation callback or not. But the way I mentioned the the should be initialized to that contact model while persisting the data to user_id field. I hope this should be enough to solve your problem.


Categories : Ruby On Rails

Related to : Associating current_user id to imported contacts list
What is the best way to create a parent/master entry in a DJANGO CRUD database app and then add associating data fields to the parent/master?
No. You don't need multiple barcode models. The fact that you have a ForeignKey from barcode to hardware already allows you to have multiple barcodes for each hardware: a ForeignKey defines a many-to-one relationship. Also, it doesn't make any sense to name the foreignkey after the model it is in: it needs to be named for the model it is pointing to, ie hardware. Finally, don't prefix your field n

Categories : Python
C# EWS copy contacts to a mailbox
You can use Impersonation like this ExchangeUserData exchangeUserData = new ExchangeUserData(); exchangeUserData.Username = "c-sharp"; exchangeUserData.Password = "c-sharp"; // c-sharp's Password ExchangeService service = Service.ConnectToServiceWithImpersonation(exchangeUserData, impersonatedUserPrincipal); Contact contact = new Contact(service); // Specify the name and how the contact should

Categories : C#
The Cordova Contacts API is inaccessible
Read the following links for phonegap/cordova project.

Categories : Android
How to test cordova contacts plugin with CADT or inside CDE?
Probably. You are right. You can file an issue to

Categories : Cordova
Sugarcrm: How to filter the accounts according to the type in a relationship field from contacts?
I edited the custom record view of accounts i.e. record.php and in the reseller field added following to array: filter_populate' => array ( 'account_type_c' => 'Resellers', ), Also, use the link for further reading. Regards

Categories : Javascript
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 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 Publishing Limited. All rights reserved.