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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:03:15+00:00 2026-06-04T03:03:15+00:00

In my app, I’m trying to make admin user can edit one attribute of

  • 0

In my app, I’m trying to make admin user can edit one attribute of a “post”

The post model is:

class PostsController < ApplicationController

before_filter :admin_user,   only: [:edit, :update]

def edit
  @post = Post.find(params[:id])
end

def update
  @post = Post.find(params[:id])
  if @post.update_attributes(params[:post][:some_attr])
     flash[:success] = "Post updated"
     redirect_to posts_path
  else
    redirect_to root_path
  end
end

The edit view is :

  <% provide(:title, "Edit post") %> 
  <h1>Update the post</h1>

  <div class="row">
    <div class="span6 offset3">
    <%= form_for(@post) do |f| %>
        <%= f.label :some_attr %>
        <%= f.text_field :some_attr %>

    <%= f.submit "Save changes", class: "btn btn-large btn-primary" %>
   <% end %>

When I try to input “123” in the some_attr test_field in edit page, it renders error:

NoMethodError in PostsController#update

undefined method `stringify_keys' for "123":String


Application Trace | Framework Trace | Full Trace
app/controllers/posts_controller.rb:22:in `update'
Request

Parameters:

{"utf8"=>"✓",
 "_method"=>"put",
 "authenticity_token"=>"EdTg+cFBnZY447oSDqSTPfb/PJ6VisJOrQ8kvichDrE=",
 "post"=>{"some_attr"=>"123"},
 "commit"=>"Save changes",
 "id"=>"17"}

What could be the problem? Which piece of the puzzle am I missing?

Thanks

  • 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-04T03:03:16+00:00Added an answer on June 4, 2026 at 3:03 am

    The problem is this line:

     if @post.update_attributes(params[:post][:some_attr])
    

    params[:post][:some_attr] is just a value. A field is not specified. If you change the line to

     if @post.update_attributes(params[:post])
    

    the attribute should update as expected.

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

Sidebar

Related Questions

app link: http://itunes.apple.com/en/app/quick-tweet/id505987287?mt=12 How can i make something like that circle? is that a
My app is expanding, but the reqs dictate that there should be only one
My app was built with SDK 2.2.1 version even before 3.0 beta appear. User
My app has several buttons which trigger different events. The user should NOT be
My app uses the android.support.v4.view.ViewPager class. For each page in the ViewPager, I want
my app has a submit feedback form. Is there a way to can capture
App Engine recently announced support for Cross Group (XG) transactions ; one would expect
My app pulls up a uitableview screen when the user clicks a settings button.
App is in prism/mvvm/mef and uses loading by attribute like StockTraderRI. My shell window
My app will have no user interface at all (exept for notifications) except for

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.