I am new to RoR and have several questions.
I have an existing DB and I want to develop an application that uses
existing DB. How do I import this DB into my application. What I mean
dont want to generate new models using rails, I want to use the existing
My DB contains tables named abc_profile, abc_friends and
One profile can have many friends and one profile can have one register.
What I have done is, I used the generate model script to generate the 3
models, and in the AbcProfile class, I wrote has_many :abc_friends and
wrote has_one :abc_register. In the AbcFriends class I wrote belongs_to
:abc_profile, and in the AbcRegister class I also wrote belongs_to
:abc_profile. Then I made a profile controller (generate controller
and wrote in it @result = AbcProfile.find(:all).
In the app/views/profile/index.rhtml file, I wrote <% @result.each do
%>, but this line is giving an error. The error is
NoMethodError in Profile#index
Showing profile/index.rhtml where line #1 raised:
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Extracted source (around line #1):
1: <% @result.each do |res| %>
Please help me with this error, and also guide me if I have done
Any help will be highly appreciated
Please reply to the email address [email protected]