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 8707179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:48:19+00:00 2026-06-13T03:48:19+00:00

class Package include DataMapper::Resource property :id, Serial property :product, String, :required => true def

  • 0
class Package
  include DataMapper::Resource
  property :id,           Serial
  property :product,      String, :required => true 

  def self.create(attributes = {})
    puts 'I am in the Object method'
    #do something here with value of product before creating a new row
    create(attributes)
  end
end


p = Package.new
p.create :product=>'myprod'

I actually want a wrapper around “create” method provided by Datamapper. So that before creating a row in Package table, I can do something with the value of “product”. But above implementation is wrong and it seems it gets lost in circular calls. I get

.......
.......
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
SystemStackError - stack level too deep:

What am I doing wrong? and how can I achieve my goal

  • 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-06-13T03:48:21+00:00Added an answer on June 13, 2026 at 3:48 am

    What you have in your code is a recursive definition. You have to avoid that.

    class Package
      include DataMapper::Resource
      property :id,           Serial
      property :product,      String, :required => true 
    
      def self.create(attributes = {})
        puts 'I am in the Object method'
        #do something here with value of product before creating a new row
        super(attributes)
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I import and use a single class from another package, will it include
i have a domain class like package trip.side import java.text.SimpleDateFormat class HotelStay { String
Class someInterface = Class.fromName(some.package.SomeInterface); How do I now create a new class that implements
This is my struts.xml <struts> <include file=example.xml/> <constant name=struts.devMode value=true /> <package name=register namespace=/register
Here's the class package db; import java.io.File; import java.io.FileInputStream; import java.sql.Connection; import java.sql.DriverManager; import
this is my custom dialog class: package com.WhosAround.Dialogs; import com.WhosAround.AppVariables; import com.WhosAround.R; import com.WhosAround.AsyncTasks.LoadUserStatus;
I'm using the NetBeans IDE(6.8). I have a DB class : package garits; import
I have two java classes as follows App1 without a package: class App1 {
VB.NET .NET 3.5 I have an aggregate class called Package as part of a
When I run my .jar, it always shows the program name as Package.Class in

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.