top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Importing mysql table in rails

0 votes
150 views

I got ruby and mysql configured successully on my windows pc. Im using mysql as default db. so I created new rails project.

I ran the cmdrake db:create:all
rake db:migrate

so I got the db created. I have existing db of country table. I imported it to the development db.

Question: Is there some files I need to modify so my ror apps will know about my country table? I'm trying to display for instance state is US from the country table.

posted Jul 14, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

You need to create a model for your table (which should be called countries, rails expects table names to be plural). I suggest working right through a good tutorial such as http://www.railstutorial.org, which is free to use online. That will show you the basics of Rails.

answer Jul 14, 2013 by anonymous
Similar Questions
+2 votes

I have a rails application, in which I am using delayed_job_active_record gem for running background jobs. While using the method .delay with an object, I am getting the following mysql error:

"INCORRECT STRING VALUE: \'XE2X9CX93"X0A ...\' FOR COLUMN \'HANDLER\' AT ROW 1"

I already searched for the above error and found that its because of the difference in encoding in mysql and rails. The solution suggested by many programmers is to alter the encoding in mysql database to utf8. But I also read that MySQL's utf8 charset only partially implements proper UTF-8 encoding. It can only store UTF-8-encoded symbols that consist of one to three bytes; encoded symbols that take up four bytes aren't supported. Which might cause trouble in some other cases. Also, when I tried to insert the value directly in mysql, it worked like a charm. Suggesting that the issue might lie elsewhere. So, can anyone please suggest the right method to rectify this problem?

Any help would be greatly appreciated.

0 votes

I am new Ruby on Rails, I had installed as described below on my machine. Could you please advise good editor compatible to the below configuration? And any additional steps required once i install these?

* MySQL 5.6.27
* Ruby 2.2
* Git
* Rails 4.0
+1 vote

I have just started with rails. I am making a attendance web app. I want to insert student attendance into attendances table and unable to do it as the form just inserts only last entry of the form. Student table and Attendances table have associations (has_many,belongs_to).

Please let me know how the form should be and controller API should look like.

...