Re: [Rails] Adding record with has_many relationship .with dynamic column_name

2015-05-22 Thread kranthi kumar
I am new to ruby on rails . I am trying to upload the data to any model , through file. so they specify the model name , and the data which needs to be dumped in to database . i am parsing each line of the file and trying to add the records . I am facing problem adding the has_many relations

Re: [Rails] Adding record with has_many relationship .with dynamic column_name

2015-05-22 Thread Colin Law
On 22 May 2015 at 07:36, kranthi kumar kranthi.3...@gmail.com wrote: I am new to ruby on rails . I am trying to upload the data to any model , through file. so they specify the model name , and the data which needs to be dumped in to database . i am parsing each line of the file and trying to

[Rails] Adding record with has_many relationship .with dynamic column_name

2015-05-21 Thread kranthi kumar
I know that we can add records like record.posts Post.find(1); but how can add the same Post.find(1) record if I have a variable that contains the name posts I have something like this column_name = posts record[column_name] Post.find(1); it is throwing an error NoMethodError

Re: [Rails] Adding record with has_many relationship .with dynamic column_name

2015-05-21 Thread Colin Law
On 21 May 2015 at 13:48, kranthi kumar kranthi.3...@gmail.com wrote: I know that we can add records like record.posts Post.find(1); but how can add the same Post.find(1) record if I have a variable that contains the name posts I have something like this column_name = posts