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

  • Home
  • SEARCH
  • 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 7787235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:35:57+00:00 2026-06-01T20:35:57+00:00

I am having trouble with datamapper not updating a model. I can create and

  • 0

I am having trouble with datamapper not updating a model. I can create and save models without issue. I have enabled raise_on_save_failure and checked the return value of update but see no errors.

Here is the model:

class UserProfile   
  include DataMapper::Resource  
  attr_accessor :id, :wants_hints, :is_beta_user  
  property :id, Serial #auto-increment integer key  
  property :is_beta_user, Boolean  
  property :wants_hints, Boolean  
  has 1, :user, :through => Resource 
end 

And here is where it is updated in the controller:

if user = User.get(request.session[:user])      
  if request.params[:user_profile]        
    beta = request.params[:user_profile].has_key?('is_beta_user')        
    hints = request.params[:user_profile].has_key?('wants_hints')        
    user.user_profile.update({:is_beta_user => beta, :wants_hints => hints}) # returns true
    Log.puts user.user_profile.errors.each {|e| Log.puts e.to_s} # returns empty list []
  end    
end

When the controller is called update always returns true, and there are never errors in the error list. The datamapper log, which is set to :debug, only shows the SELECT queries for retrieving the user and user_profile and that is all. Why would I be able to save a newly created model, but not be allowed to update that same model?

  • 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-01T20:35:59+00:00Added an answer on June 1, 2026 at 8:35 pm

    Removing attr_accessor fixed the problem. From my research attr_accessor is used for attributes not in the database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

having trouble coming up with search parameters for this issue, so I can't find
Having Trouble with Entity Framework. I have been populating EntityReferences with an EntityKey inorder
I'm trying to use Datamapper in my Rails 3.1 application and I'm having trouble
Having trouble with pattern and replacement. How can I make the replacement echo a
Having trouble with some select statements. I have 2 tables. sms_log and sms_messages. sms_log
Having trouble with grepping and cutting at the same time I have a file
Having trouble here and not quite sure how to do it. I've attempted jQuery
Having trouble when trying to create a class using another class(and 2 inner classes),
Having trouble getting this to apply in MySQL Workbench 5.2.15 DELIMITER // CREATE DEFINER=`potts`@`%`
Having trouble diagnosing/fixing an issue on a website where the Wordpress sidebar won't appear

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.