Forum: JRuby how to get username

3e580e9facde48bbb1fe4148b7d54005?d=identicon&s=25 Veerendra P. (veerendra_p)
on 2013-07-18 13:03
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.

Regards
Veerendra Patil
Caa2df9372ffa0a9e95b2bab1e8fea34?d=identicon&s=25 Karol Bucek (Guest)
on 2013-07-19 15:00
(Received via mailing list)
Hi Veerendra, do it the same way as in Ruby :)

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
end

class Risk < ActiveRecord::Base
  belongs_to :member
end

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

puts( member.firsname << ' ' << member.lastname << ' ' <<
member.risk.name )

Next time - maybe with a few details (the more details the better
answer)
ask this on he Rails user mailing list
or start somewhere here:
http://guides.rubyonrails.org/association_basics.html

Have a great week-end, K.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.