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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:29:46+00:00 2026-06-04T16:29:46+00:00

In my Business model, when I try to create a business and an error

  • 0

In my Business model, when I try to create a business and an error occurs, I noticed after the POST it gets rid of my shared/page_header partial:

def page_title
  "#{@page_title}"
end

<% unless @page_title.blank? %>
<div class="row">
   <div class="page-header span12">
      <h1><%= @page_title %></h1>
   </div>
</div>
<% end %>

def new
  @business = Business.new
  @page_title = "Add Business"
end

def create
  @business = Business.new(params[:business])
  if @business.save
    redirect_to :back, :notice => "This Business was successfully added."
  else
    render :new, :notice => "It seems there was an error. Please try again."
  end
end

Now I notice I start on /businesses/new but after the POST it goes to /businesses. Someone told me this was normal, but I never seen this type of behavior until now. If it helps, the new and create actions are the only ones in my Business resource. What can I do to get this working?

  • 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-04T16:29:48+00:00Added an answer on June 4, 2026 at 4:29 pm

    Just add @page_title = “Add Business” to your create method. “render :new” renders the new template but not executes the new method.

    Using render with :action is a frequent source of confusion for Rails newcomers. The specified action is used to determine which view to render, but Rails does not run any of the code for that action in the controller. Any instance variables that you require in the view must be set up in the current action before calling render. from http://guides.rubyonrails.org/layouts_and_rendering.html#using-render

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

Sidebar

Related Questions

I try to put as much business logic as possible in my Domain Model.
In my business model I have Entity class (IPoint interface ) that has a
I have a basic Django model like: class Business(models.Model): name = models.CharField(max_length=200, unique=True) email
I have been adding error and business validation to my app, and when I
I have a 'Business' model which has_many 'Hours'. Each Hour record has a start_time
I have a City model and a Business model. Business belogs_to :city Now I
Suppose I'm entertaining a business model that offers free access to my propritary data
I've found view models to be very useful for splitting user interface and business
Alright. I am using a Modal box pop up window to display business details
Business World 1256987 monthly 10 2009-10-28 Business World 1256987 monthly 10 2009-09-23 Business World

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.