I have two files.
clans.rb
class Clans < ActiveRecord::Base
belongs_to :User
end
user.rb
class User < ActiveRecord::Base
has_one :Clan
end
I also have two mysql tables.
clans: id | name | prefix | description | user_id
users: id | username | password | email | bindcode
clans.user_id being users.id of the clan leader.
In my code I can use the following in show.html.erb and it gives me the clan name.
<%= Clans.find(params[:id]).name %>
But I want to be able to do: Clans.find(params[:id]).leader.(users fields) Example:
<%= Clans.find(params[:id]).leader.username %>
How can I achieve this?