# about action create..

**URL:** <https://discuss.rubyonrails.org/t/about-action-create/26814>\
**Category:** rubyonrails-talk\
**Created:** [March 25, 2008, 10:55am UTC](https://discuss.rubyonrails.org/t/about-action-create/26814 "2008-03-25T10:55:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![isfrog](https://avatars.discourse-cdn.com/v4/letter/i/87869e/32.png) [@isfrog](https://discuss.rubyonrails.org/u/isfrog)\
**Post date:** [March 25, 2008, 10:55am UTC](https://discuss.rubyonrails.org/t/about-action-create/26814/1 "2008-03-25T10:55:13Z")

</div>

there i hava a model named Person the controller is People in the new.html.erb file function form\_for(@person) make the start form tag #@person=Person.new

i think it'll call "create" action in PeopleController when invoke submit button but not! it just renders index.html.erb and never access to action create

sorry to my poor English 😃wish i hava descriped it clearly...

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [March 25, 2008, 6:28pm UTC](https://discuss.rubyonrails.org/t/about-action-create/26814/2 "2008-03-25T18:28:05Z")

</div>

Your &nbsp;&nbsp;@person = Person.new should be in the people\_controller...

I'd say start with a new rails project...

Generate a scaffold for your person model

-\> ruby script/generate scaffold person last\_name:string first\_name:string dob:datetime

look at the source that is written for you, i.e., new.html.erb has

-\> \<% form\_for(@person) do |f| %\> -\> ... field stuff... -\> \<%= f.submit "Create" %\> -\> \<% end %\>

setup your database, and all that... then browse to [http://localhost:3000/people](http://localhost:3000/people) - click the "New person" link, and look at the page source if you're curious

add a person, fill out the fields and submit. That should hit your people\_controller create method (it's a POST, after all).

While not necessarily how you'll end up writing your app in the future, the scaffolded code is a great resource to read in the beginning to see how Rails fits it all together.

---

<div class="post-metadata">

**Author:** ![isfrog](https://avatars.discourse-cdn.com/v4/letter/i/87869e/32.png) [@isfrog](https://discuss.rubyonrails.org/u/isfrog)\
**Post date:** [March 26, 2008, 3:12am UTC](https://discuss.rubyonrails.org/t/about-action-create/26814/3 "2008-03-26T03:12:07Z")

</div>

thx ! here is my source code . PeopleController def new @person=Person.new end &nbsp;&nbsp;def create &nbsp;&nbsp;&nbsp;@person = Person.new(params[:person])

&nbsp;&nbsp;&nbsp;&nbsp;respond\_to do |format| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if @person.save &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flash[:notice] = 'Product was successfully created.' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.html &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.xml { render :xml =\> @person, :status =\> :created, :location =\> @product } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flash[:notice]="dont saved" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.html { render :action =\> "new" } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.xml { render :xml =\> @person.errors, :status =\> :unprocessable\_entity } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;end

new.html.erb \<% form\_for(@person) do |f| %\> \<%=f.text\_field :first\_name %\> ..... \<%end%\>

something wrong here ?

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [March 26, 2008, 3:32am UTC](https://discuss.rubyonrails.org/t/about-action-create/26814/4 "2008-03-26T03:32:35Z")

</div>

i guess there is something wrong with ROUTER

first i insert data items to mysql database via PHPMYADMIN, the INDEX method show out them but when i click the “show,edit,destroy"links rails give me the response "No action responded to 1" the number is person id. anyone can tell my why?

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [March 26, 2008, 3:39am UTC](https://discuss.rubyonrails.org/t/about-action-create/26814/5 "2008-03-26T03:39:01Z")

</div>

Yes!just the ROUTER.rb! here is the code &nbsp;&nbsp;map.resources :people &nbsp;&nbsp;# Install the default routes as the lowest priority. &nbsp;&nbsp;map.connect ':controller/:action/:id' &nbsp;&nbsp;map.connect ':controller/:action/:id.:format' at the beginning i put "map.resources :people" on the end . i think this cause something wrong
