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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:21:27+00:00 2026-06-16T06:21:27+00:00

After setting up my config.ru and gemfile, my post no longer wants to work.

  • 0

After setting up my config.ru and gemfile, my post no longer wants to work.

First, I have to have my DataMapper.setup in my main.rb and I cannot run any DataMapper methods in my irb.

Second, whenever I submit a form via POST for some data to be saved to my db Sinatra returns with…

NoMethodError at /
undefined method `each' for "asdfasdf":String

file: resource.rb
location: attributes=
line: 329

main.rb

#Required Gems
  require 'sinatra'
  require 'data_mapper'

DataMapper.setup(:default, ENV['DATABASE_URL'] || 'postgres://host:password!@localhost
/blog_development')


#Database Migration
  class Code
    include DataMapper::Resource
    property :id,           Serial
    property :code,         String, :required => true
    property :translation,  String
    property :completed_at, DateTime
  end

#Set up Migration
  DataMapper.finalize

#Routes Section
get '/' do
  @codes = Code.all
  slim :index
end

#Get Code
get '/:code' do
  @morse_code = params[:code]
  slim :code
end

#POST Code
post '/' do
  @code = Code.create params[:code]
  redirect to('/')
end

Gemfile

source :rubygems

gem "sinatra", "~> 1.3.3"

gem "data_mapper", "~> 1.2.0"

gem "slim", "~> 1.3.4"

gem "dm-postgres-adapter", "~> 1.2.0"

config.ru

require 'bundler'

Bundler.require

require './main'

DataMapper.setup(:default, ENV['DATABASE_URL'] || 'postgres://host:password@localhost

/blog_development')

run Sinatra::Application

Note that asdfasdf is the text I put in the input box for the form before submit.

For the repo in case anyone wants to live test it… https://github.com/thejourneydude/morsecode

  • 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-16T06:21:28+00:00Added an answer on June 16, 2026 at 6:21 am

    You are calling Code.create params[:code]. Try Code.create :code => params[:code]. This way the string does not end up where datamapper expects an attribute hash.

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

Sidebar

Related Questions

I have a weird problem where after setting nocheck on a foreign constraint and
I recently installed Trac on windows for the first time. After setting everything up
i have problems with a really basic thing. setting properties after instantiation a UIViewController-
after setting all config file and runtime options for charset that i can find
I decided to move Entity Connection String from app.config to code. However after setting
After adding these settings in web.config for increasing session timeout: <sessionState mode=InProc stateConnectionString=tcpip=127.0.0.1:42424 stateNetworkTimeout=240
After setting db to some arbitrary value, i am not able to perform any
How to enumerate items of Spark List component after setting dataProvider property? I mean
I am currently building a measurement unit convertion app for Windows Phone. After setting
I'm having issues properly setting up my Hibernate configuration. After trying to extend the

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.