--- Z@m ---
2009-Feb-27 13:03 UTC
what / when calls create function in an ActionController ?
Hi friends , i am newbie and was trying to learn rails by following a tutorial which uses attachment_fu to upload videos .! every thing was working till i edited something somewhere ! the problem is that nothing happens when i click the submit button the new.html.erb is as follows and it displays well too <h2>Upload Advertisements 1</h2><br /> <% form_for(@advertisement, :html => { :multipart => true }) do |f| %> <%= f.error_messages %> <table> <tr> <td><%= f.label :title %>: </td><td><%= f.text_field :title %></ td> </tr> <tr> <td><%= f.label :description %>: </td><td><%f.text_area :description %></td> </tr> <tr> <td><%= f.label :advertisement %>: </td><td><%f.file_field :uploaded_data %></td> </tr> <tr><td><%= f.submit ''Submit'' %> - <%= link_to ''Back'', advertisements_path %></td></tr> </table> <% end %> and the create function in the Controller is as follows def create @advertisement = Advertisement.new(params[:advertisement]) #@advertisement.write_to_log if @advertisement.save @advertisement.convert flash[:notice] = ''Advertisement has been uploaded'' redirect_to :action => ''index'' else @advertisements = Advertisement.find(:all) render :action => ''new'' end end even deleting the create function , it shows no error but returns to index page when submit button clicked . it seems that this function is not called properly help appreciated thanks in advance --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Starr Horne
2009-Feb-27 15:33 UTC
Re: what / when calls create function in an ActionController ?
> even deleting the create function , it shows no error but returns to > index page when submit button clicked . it seems that this function is > not called properlyHave you set up your routes.rb file? SH --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
http://api.rubyonrails.com/classes/ActionView/Helpers/FormHelper.html example taken form the above link: # Note: a @person variable will have been created in the controller. # For example: @person = Person.new <% form_for :person, @person, :url => { :action => "create" } do |f| %> <%= f.text_field :first_name %> <%= f.text_field :last_name %> <%= submit_tag ''Create'' %> <% end %> what you got is this: <% form_for(@advertisement, :html => { :multipart => true }) do |f| %> <%= f.text_field :title %> <%= f.text_area :description %> <%# ... %> <%= f.submit ''Submit'' %> now try changing your first line to: <% form_for :advertisement, @advertisment, :url => { :action => "create" }, :html => { :multipart => true } do |f| %> hope this helps. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
--- Z@m ---
2009-Feb-28 01:31 UTC
Re: what / when calls create function in an ActionController ?
i tried <% form_for :advertisement, @advertisment, :url => { :action => "create" }, :html => { :multipart => true } do |f| %> but the result is the same ! will on clicking the submit button automatically call the create function? how can i know weather it is called or not --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
--- Z@m ---
2009-Feb-28 04:11 UTC
Re: what / when calls create function in an ActionController ?
My routes.db ActionController::Routing::Routes.draw do |map| map.resources :advertisements map.root :controller => "home" map.connect '':controller/:action/:id'' map.connect '':controller/:action/:id.:format'' end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> how can i know weather it is called or notset a debugger. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---