Re: [Rails] create dynamic model and store the values to table

2017-01-22 Thread parzival wade
Thank you David On Thursday, January 19, 2017 at 5:59:48 PM UTC+1, David Williams wrote: > > vocabularies = File.read(Rails.root.join('lib', 'seeds', 'words.csv')) > csv = CSV.parse(vocabularies, :headers => true, :encoding => 'ISO-8859-1') > csv.each do |row| > t = Vocabulary.new > t.word_col

Re: [Rails] create dynamic model and store the values to table

2017-01-19 Thread David Williams
This is for your seed file. You can create a task for it as well. On Thursday, January 19, 2017 at 11:59:48 AM UTC-5, David Williams wrote: > > vocabularies = File.read(Rails.root.join('lib', 'seeds', 'words.csv')) > csv = CSV.parse(vocabularies, :headers => true, :encoding => 'ISO-8859-1') > csv.

Re: [Rails] create dynamic model and store the values to table

2017-01-19 Thread David Williams
vocabularies = File.read(Rails.root.join('lib', 'seeds', 'words.csv')) csv = CSV.parse(vocabularies, :headers => true, :encoding => 'ISO-8859-1') csv.each do |row| t = Vocabulary.new t.word_column1 = row[0] t.word_column2 = row[1] t.word_column3 = row[2] t.word_column4 = row[3] t.word

Re: [Rails] create dynamic model and store the values to table

2017-01-15 Thread parzival wade
Hi Daynthan, I have the same problem. So I see you got working solution. Please, can you post final version of working important files? Thank you. On Friday, January 6, 2017 at 2:45:29 PM UTC+1, daynthan kabilan wrote: > > Thank you Tamosus pontik. > > I have done the task using this keyword requ

Re: [Rails] create dynamic model and store the values to table

2017-01-06 Thread Daynthan Kabilan
Thank you Tamosus pontik. I have done the task using this keyword require "#{dynamic_model_name}" On Thu, Jan 5, 2017 at 7:24 PM, tamouse pontiki wrote: > On Thu, Jan 5, 2017 at 2:40 AM Daynthan Kabilan > wrote: > >> Hi Tamosus pontik, >> >> Thanks for your reply. >> The model file is created

Re: [Rails] create dynamic model and store the values to table

2017-01-05 Thread tamouse pontiki
On Thu, Jan 5, 2017 at 2:40 AM Daynthan Kabilan wrote: > Hi Tamosus pontik, > > Thanks for your reply. > The model file is created dynamically based on this code. > And after you write that file, you need to require it for Rails to use it. That's why the constant is undefined. Do you know how t

Re: [Rails] create dynamic model and store the values to table

2017-01-05 Thread Daynthan Kabilan
Hi Tamosus pontik, Thanks for your reply. The model file is created dynamically based on this code. model_file = File.join("app", "models", fname.singularize+".rb") model_name = fname.singularize.capitalize File.open(model_file, "w+") do |f| f << "class #{model_name} < ActiveRecord

Re: [Rails] create dynamic model and store the values to table

2017-01-04 Thread tamouse pontiki
On Wed, Jan 4, 2017 at 8:57 AM Daynthan Kabilan wrote: > Hi, > > I have a CSV upload option and need to create a table and model based on > the CSV colums. > > We allow to upload different kind of CSV file formats and each file upload > will create new table and info will be stored accordingly. I

[Rails] create dynamic model and store the values to table

2017-01-04 Thread Daynthan Kabilan
Hi, I have a CSV upload option and need to create a table and model based on the CSV colums. We allow to upload different kind of CSV file formats and each file upload will create new table and info will be stored accordingly. I have created a table with columns based on CSV file header and also