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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:23:57+00:00 2026-06-03T08:23:57+00:00

In my create action, method new acts like create. def create @page = Page.new(params[:page].merge(:user_id

  • 0

In my create action, method new acts like create.

def create
  @page = Page.new(params[:page].merge(:user_id => current_user.id ))
  if @page.save
    flash[:notice] = t("success")
    redirect_to pages_path
  else
    render :new
  end
end

ActiveRecord creates new object in database while I’m using new with params. Page.new works fine in new action in my controller. What can be the reason? There is no overridden method new and no callbacks (before_save, before_create etc) in my model. Any help would be appreciated.

UPDATE – code from debugger

.../app/controllers/pages_controller.rb:48
@page = Page.new(params[:page].merge(:user_id => current_user.id ))
(rdb:25) @page
nil
(rdb:25) n
.../app/controllers/pages_controller.rb:49
if @page.save
(rdb:25) @page
#<Page id: 80 ... >
(rdb:25) Page.last
#<Page id: 80 ... >
(rdb:25) @page.save
false
  • 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-03T08:23:58+00:00Added an answer on June 3, 2026 at 8:23 am

    Reason (method in model which can change status in workflow):

    def status=(state_name)
      states = [self.current_state.to_sym]
      possible_states.each {|t| states<< t[1]}
      unless state_name.blank?
        if states.include? state_name
        process_event! state_name
        end
      end
    end
    

    Ugly fix

    def create
      @page = Page.new
      if @page.update_attributes(params[:page].merge(:user_id => current_user.id )) && @page.save
        flash[:notice] = t("success")
        redirect_to pages_path
      else
        render :new
      end
    end
    

    Mistake was quite silly and I’m not proud of my solution. Anyway, thanks for help:)

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

Sidebar

Related Questions

in a controller I have a create action def create params[:note] @note = current_user.notes.new(params[:note])
Using Rails 3.1.0 def create @practice = Practice.new(params[:practice]) respond_to do |format| if (current_user.practices <<
I have a create action like so in a rails controller: def create @user
I am trying to create an extension method for the generic delegate Action<T> to
my controller can return different views depending on action method logic. Action method 'Create'
I'm checking ModelState.IsValid in my controller action method that creates an Employee like this:
i've got the following Action Method I'm trying to moq test. Notice the AcceptVerbs
I use a helper method to create sections in my view: @helper CreateFacetSection(WebViewPage page,
Scenario: The Create action method will pass an uninitialized instance of Person to the
I am using ASP.NET MVC 3. I have an action method called New. When

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.