isfrog-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Mar-25 10:55 UTC
about action create..
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 :D wish i hava descriped it clearly... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Your @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 - 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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
isfrog-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Mar-26 03:12 UTC
Re: about action create..
thx ! here is my source code . PeopleController def new @person=Person.new end def create @person = Person.new(params[:person]) respond_to do |format| if @person.save flash[:notice] = ''Product was successfully created.'' format.html format.xml { render :xml => @person, :status => :created, :location => @product } else flash[:notice]="dont saved" format.html { render :action => "new" } format.xml { render :xml => @person.errors, :status => :unprocessable_entity } end end end new.html.erb <% form_for(@person) do |f| %> <%=f.text_field :first_name %> ..... <%end%> something wrong here ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yes!just the ROUTER.rb! here is the code map.resources :people # Install the default routes as the lowest priority. map.connect '':controller/:action/:id'' map.connect '':controller/:action/:id.:format'' at the beginning i put "map.resources :people" on the end . i think this cause something wrong -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---