Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7572091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:50:16+00:00 2026-05-30T15:50:16+00:00

I have a simple association of header and item (1 : 1). when I

  • 0

I have a simple association of header and item (1 : 1). when I say

class Header 
include DataMapper::Resource
  property :id, Serial
  property :somedata
  has 1, :item
end

class Item
include DataMapper::Resource
  property :id, Serial
  property :name, String
  attr_accessor: full_name, String
  belongs_to :user
end
Header.get(1).item

I would like to have a hook for item for doing some translation(say some initialization for full_name~updating the attr_accessor fields). This has to be generalized as I don’t want do a before method item on the header ..but hook method the item model. so that however the item is called the translation/initialization happens.

How can this be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:50:17+00:00Added an answer on May 30, 2026 at 3:50 pm

    I figured it myself. wanted to update in case it might be useful other people. just need define a method for that attribute.

    def full_name
      "Mr"+full_name
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make simple many-to-one association, using NHibernate.. I have class Recruit with
Let's say I have: class Foo < ActiveRecord::Base has_many :bar end class Bar <
Consider a simple association... class Person has_many :friends end class Friend belongs_to :person end
I have a simple has_one/belongs_to relationship between two models. This is a new association
I have simple class with width and height member fields which define number of
I have a really simple association with the Devise user object where each user
I have a simple OneToMany association between 2 object Parent & Child as shown
i have a simple associations: class Account < ActiveRecord::Base has_many :users accepts_nested_attributes_for :users validates_presence_of
I am using ExtJS 4.1.0 Say I have a couple simple model's connected via
quick best-practices question(s). I have as association as follows: User hasOne UserBasicInfo UserBasicInfo has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.