I have been building a small app to import a cv from linkedin. Displaying the information is working out perfect, but saving it to the database is turning out to be a challenge. The full source code is at https://github.com/brunoamaral/lwork and the source code of the import function is as follows: def importcv @user = User.find_by_username(params[:username]) client = LinkedIn::Client.new(@linkedin_apikey, @linkedin_secret) t = current_user.authentications.find_by_provider(''linked_in'') client.authorize_from_access(t.token, t.secret) @cv = client.profile(:fields => [:headline, :first_name, :last_name, :educations, :positions]) @user.positions << @cv.positions @user.positions.save end When running it, I get the message: undefined method `match'' for LinkedIn::Position::Resource:Class The model adds the following to users: has_many :positions, :class_name => LinkedIn::Position::Resource What bugs me more is that I don''t even know where to start looking for an answer to this, so any hints on where to search and what to look for are welcome. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 22 April 2011 18:09, Bruno Amaral <mail-S2ydJG5fPKHivB4pSPl/wg@public.gmane.org> wrote:> I have been building a small app to import a cv from linkedin. > Displaying the information is working out perfect, but saving it to > the database is turning out to be a challenge. > ... > When running it, I get the message: > undefined method `match'' for LinkedIn::Position::Resource:Class >match is a method of String, so I wonder whether it is getting called on the above type instead of a string. The error should show a stack trace which should show you which line of your code it is failing on. Post the complete error and trace if you cannot work it out. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
The error message mentions line 44: @user.positions << @cv.positions @user.positions.save the full output is here: http://dl.dropbox.com/u/109441/errormessagerails.html @cv.positions is an array, so from what you''re telling me it should not use "match" as a method. On Apr 22, 6:38 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 22 April 2011 18:09, Bruno Amaral <m...-S2ydJG5fPKHivB4pSPl/wg@public.gmane.org> wrote: > > > I have been building a small app to import a cv from linkedin. > > Displaying the information is working out perfect, but saving it to > > the database is turning out to be a challenge. > > ... > > When running it, I get the message: > > undefined method `match'' for LinkedIn::Position::Resource:Class > > match is a method of String, so I wonder whether it is getting called > on the above type instead of a string. The error should show a stack > trace which should show you which line of your code it is failing on. > Post the complete error and trace if you cannot work it out. > > Colin-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 22 April 2011 22:15, Bruno Amaral <mail-S2ydJG5fPKHivB4pSPl/wg@public.gmane.org> wrote: Please don''t top post, it makes it difficult to follow the thread. Insert your reply at appropriate points in previous message. Thanks.> The error message mentions line 44: > -AG0hYIjz8F7YZKLFoIwPXw@public.gmane.org << @cv.positions > -AG0hYIjz8F4BIPNuqpGjWt+FlJJrsOAv@public.gmane.org > > the full output is here: http://dl.dropbox.com/u/109441/errormessagerails.htmlDon''t you get a full error trace, in the server terminal window or log/development.log?> > @cv.positions is an array, so from what you''re telling me it should > not use "match" as a method.You realise that, if user.positions is also an array that @user.positions << @cv.positions will attempt to add the whole array @cv.positions as a single element on the end of @user.positions. Not append the contents of @cv.positions as multiple new elements. Are you sure you do not want @user.positions += @cv.positions I don''t know what @user.positions is of course so I may be misinterpreting something. Colin> > On Apr 22, 6:38 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> On 22 April 2011 18:09, Bruno Amaral <m...-S2ydJG5fPKHivB4pSPl/wg@public.gmane.org> wrote: >> >> > I have been building a small app to import a cv from linkedin. >> > Displaying the information is working out perfect, but saving it to >> > the database is turning out to be a challenge. >> > ... >> > When running it, I get the message: >> > undefined method `match'' for LinkedIn::Position::Resource:Class >> >> match is a method of String, so I wonder whether it is getting called >> on the above type instead of a string. The error should show a stack >> trace which should show you which line of your code it is failing on. >> Post the complete error and trace if you cannot work it out. >> >> Colin > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 23, 9:24 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 22 April 2011 22:15, Bruno Amaral <m...-S2ydJG5fPKHivB4pSPl/wg@public.gmane.org> wrote: > > Please don''t top post, it makes it difficult to follow the thread. > Insert your reply at appropriate points in previous message. Thanks. > > > The error message mentions line 44: > > -AG0hYIjz8F7YZKLFoIwPXw@public.gmane.org << @cv.positions > > -AG0hYIjz8F4BIPNuqpGjWt+FlJJrsOAv@public.gmane.org > > > the full output is here:http://dl.dropbox.com/u/109441/errormessagerails.html > > Don''t you get a full error trace, in the server terminal window or > log/development.log? >I do have a full trace at http://pastie.org/1825323 and the server log is http://pastie.org/1825336> You realise that, if user.positions is also an array that > @user.positions << @cv.positions > will attempt to add the whole array @cv.positions as a single element > on the end of @user.positions. Not append the contents of > @cv.positions as multiple new elements. Are you sure you do not want > @user.positions += @cv.positions >cv.positions is the information the user has in the experience bit of their LinkedIn profile. composed of user_id: integer, company: string, end_month: string, end_year: string, start_month: string, start_year: string Using += resulted in the exact same error message, which is strange I was hoping to at least get more information from rails. Maybe it means the problem is not the line 44 but something else. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 23 April 2011 13:59, Bruno Amaral <mail-S2ydJG5fPKHivB4pSPl/wg@public.gmane.org> wrote:> > On Apr 23, 9:24 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> On 22 April 2011 22:15, Bruno Amaral <m...-S2ydJG5fPKHivB4pSPl/wg@public.gmane.org> wrote: >> >> Please don''t top post, it makes it difficult to follow the thread. >> Insert your reply at appropriate points in previous message. Thanks. >> >> > The error message mentions line 44: >> > -AG0hYIjz8F7YZKLFoIwPXw@public.gmane.org << @cv.positions >> > -AG0hYIjz8F4BIPNuqpGjWt+FlJJrsOAv@public.gmane.org >> >> > the full output is here:http://dl.dropbox.com/u/109441/errormessagerails.html >> >> Don''t you get a full error trace, in the server terminal window or >> log/development.log? >> > I do have a full trace at http://pastie.org/1825323 > > and the server log is http://pastie.org/1825336 > >> You realise that, if user.positions is also an array that >> @user.positions << @cv.positions >> will attempt to add the whole array @cv.positions as a single element >> on the end of @user.positions. Not append the contents of >> @cv.positions as multiple new elements. Are you sure you do not want >> @user.positions += @cv.positions >> > > cv.positions is the information the user has in the experience bit of > their LinkedIn profile. > composed of user_id: integer, company: string, end_month: string, > end_year: string, start_month: string, start_year: stringDo you mean each member of the array (or association) positions is one of those. I am a bit confused by the line @user.positions.save. Can you do save on an array? Or is positions a single record, in which case it should be called position, singular. Is there a Position model then, with cv has_many positions ? What happens if you do something like @cv.postions.each do |position| @user.positions << position end Can you post the model definitions? Not all the methods just the definitions and associations and so on. Have you used ruby-debug or a similar to technique to break in and check that all the variables are as you expect. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
adding ruby-debug froze the import page, but I will keep trying to check the variables as you said. about the model, the source code is in the github project https://github.com/brunoamaral/lwork/blob/master/app/models/user.rb class User < ActiveRecord::Base has_many :authentications has_many :positions, :class_name => LinkedIn::Position::Resource -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-Apr-23 21:12 UTC
Re: undefined method ''match'' with the Linkedin Gem
On Apr 23, 5:09 pm, Bruno Amaral <m...-S2ydJG5fPKHivB4pSPl/wg@public.gmane.org> wrote:> adding ruby-debug froze the import page, but I will keep trying to > check the variables as you said. > > about the model, the source code is in the github projecthttps://github.com/brunoamaral/lwork/blob/master/app/models/user.rb > > class User < ActiveRecord::Base > > has_many :authentications > has_many :positions, :class_name => LinkedIn::Position::ResourceThis looks wrong, since :class_name is supposed to be a string and LinkedIn::Position::Resource isn''t Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 23, 10:12 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > has_many :authentications > > has_many :positions, :class_name =>LinkedIn::Position::Resource > > This looks wrong, since :class_name is supposed to be a string andLinkedIn::Position::Resource isn''tHowever, not using it only returns Position(#2174910600) expected, got LinkedIn::Position::Resource(#2173297260) I am thinking about taking a different approach, since I can''t figure out how to save the information I need in one go the other option is to try to build an import form. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.