How to get username

Hi ,

i have a class “members” it has memberid,firstname,lastname and email
and there is another class “risks” in tht memberid is referenced and
storing the database table,now i want to show in risks report member
name based on the memberid,

I am new to Jruby,
please help on this.

Veerendra Patil

Hi Veerendra, do it the same way as in Ruby :slight_smile:

If you’re new do that one as well you need to choose an ORM …
assuming you use Rails/ActiveRecord you do something like :

class Member < ActiveRecord::Base
has_one :risk

class Risk < ActiveRecord::Base
belongs_to :member

id = params[:memberid]
member = Member.find(id)

puts( member.firsname << ’ ’ << member.lastname << ’ ’ << )

Next time - maybe with a few details (the more details the better
ask this on he Rails user mailing list
or start somewhere here:

Have a great week-end, K.