Hi all !
I''ve got a problem in my application. I''ve written a
bug_reports
controller. It is pretty RESTful, there are index, new and create
actions. Everytime I submit a new bug_report, the index action is
called, not the create action, you can see the log here:
http://pastie.org/258857.
My form looks like this:
<fieldset id="bugreport">
<% form_for @bug_report, :url => bug_reports_path do |f| -%>
  <div>
    <%= f.text_field :title, :value => "Title" %>
  </div>
  <div>
    <%= f.text_area :body %>
  </div>
  <div>
    <%= f.submit "Submit", :disable_with =>
''Submiting...'' %>
  </div>
<% end -%>
</fieldset>
My routes.rb contains this line: map.resources :bug_reports
And finally, my BugReportsController looks like this:
class BugReportsController < ApplicationController
  login_required
  def index
    @bug_reports = BugReport.all
  end
  def new
    @bug_report = BugReport.new
  end
  def create
    @bug_report = BugReport.new params[:bug_report]
    if @bug_report.save
      flash[:notice] = "Thank you for submitting this bug."
    else
      flash[:warning] = "Your bug report was not saved. Please try
again."
    end
    redirect_to root_url
  end
end
This error doesn''t occur in other parts of my app. I really
don''t know
why this happens, I hope you can help me. Thank you very much in
advance,
Christoph
PS: I''ve written a small patch regarding
options_from_collection_for_select. You can find it here:
http://rails.lighthouseapp.com/projects/8994/tickets/890-in-options_from_collection_for_select-text-value_method-are-chainable.
I would be happy if someone would give me feedback on this.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
On Sun, Aug 24, 2008 at 1:27 AM, Christoph <chrisi.dibiasi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi all ! > I''ve got a problem in my application. I''ve written a bug_reports > controller. It is pretty RESTful, there are index, new and create > actions. Everytime I submit a new bug_report, the index action is > called, not the create action, you can see the log here: > http://pastie.org/258857. > My form looks like this: > <fieldset id="bugreport"> > <% form_for @bug_report, :url => bug_reports_path do |f| -%> > <div> > <%= f.text_field :title, :value => "Title" %> > </div> > <div> > <%= f.text_area :body %> > </div> > <div> > <%= f.submit "Submit", :disable_with => ''Submiting...'' %> > </div> > <% end -%> > </fieldset> >Try using the following: <% form_for(@bug_report) do |f| -%> Good luck, -Conrad --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
No, this doesn''t help. The form seems to be correct regardless if I specify the url or not: <form id="new_bug_report" class="new_bug_report" method="post" action="/bug_reports"> On 24 Aug., 12:09, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sun, Aug 24, 2008 at 1:27 AM, Christoph <chrisi.dibi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi all ! > > I''ve got a problem in my application. I''ve written a bug_reports > > controller. It is pretty RESTful, there are index, new and create > > actions. Everytime I submit a new bug_report, the index action is > > called, not the create action, you can see the log here: > >http://pastie.org/258857. > > My form looks like this: > > <fieldset id="bugreport"> > > <% form_for @bug_report, :url => bug_reports_path do |f| -%> > > <div> > > <%= f.text_field :title, :value => "Title" %> > > </div> > > <div> > > <%= f.text_area :body %> > > </div> > > <div> > > <%= f.submit "Submit", :disable_with => ''Submiting...'' %> > > </div> > > <% end -%> > > </fieldset> > > Try using the following: > > <% form_for(@bug_report) do |f| -%> > > Good luck, > > -Conrad--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, I was able to get it working here without any issues.  I built the
application from scratch.  Here''s the new.html.erb:
<h1>New bug_report</h1>
<% form_for(@bug_report) do |f| %>
  <%= f.error_messages %>
  <p>
    <%= f.label :title %><br />
    <%= f.text_field :title %>
  </p>
  <p>
    <%= f.label :body %><br />
    <%= f.text_area :body %>
  </p>
  <p>
    <%= f.submit "Create" %>
  </p>
<% end %>
<%= link_to ''Back'', bug_reports_path %>
-Conrad
On Sun, Aug 24, 2008 at 3:27 AM, Christoph
<chrisi.dibiasi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> No, this doesn''t help. The form seems to be correct regardless if
I
> specify the url or not:
> <form id="new_bug_report" class="new_bug_report"
method="post"
> action="/bug_reports">
>
> On 24 Aug., 12:09, "Conrad Taylor"
<conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > On Sun, Aug 24, 2008 at 1:27 AM, Christoph
<chrisi.dibi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> wrote:
> >
> > > Hi all !
> > > I''ve got a problem in my application. I''ve
written a bug_reports
> > > controller. It is pretty RESTful, there are index, new and create
> > > actions. Everytime I submit a new bug_report, the index action is
> > > called, not the create action, you can see the log here:
> > >http://pastie.org/258857.
> > > My form looks like this:
> > > <fieldset id="bugreport">
> > > <% form_for @bug_report, :url => bug_reports_path do |f|
-%>
> > >  <div>
> > >    <%= f.text_field :title, :value => "Title"
%>
> > >  </div>
> > >  <div>
> > >    <%= f.text_area :body %>
> > >  </div>
> > >  <div>
> > >    <%= f.submit "Submit", :disable_with =>
''Submiting...'' %>
> > >  </div>
> > > <% end -%>
> > > </fieldset>
> >
> > Try using the following:
> >
> > <% form_for(@bug_report) do |f| -%>
> >
> > Good luck,
> >
> > -Conrad
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Don''t you think the error is somewhere in the code handling the request. The form is generated correct, and it also sends the request correct to the server, with all parameters, as you can see in the log here: http://pastie.org/258857 On 24 Aug., 12:52, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, I was able to get it working here without any issues. I built the > application from scratch. Here''s the new.html.erb: > <h1>New bug_report</h1> > > <% form_for(@bug_report) do |f| %> > <%= f.error_messages %> > > <p> > <%= f.label :title %><br /> > <%= f.text_field :title %> > </p> > <p> > <%= f.label :body %><br /> > <%= f.text_area :body %> > </p> > <p> > <%= f.submit "Create" %> > </p> > <% end %> > > <%= link_to ''Back'', bug_reports_path %> > > -Conrad > > On Sun, Aug 24, 2008 at 3:27 AM, Christoph <chrisi.dibi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > No, this doesn''t help. The form seems to be correct regardless if I > > specify the url or not: > > <form id="new_bug_report" class="new_bug_report" method="post" > > action="/bug_reports"> > > > On 24 Aug., 12:09, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Sun, Aug 24, 2008 at 1:27 AM, Christoph <chrisi.dibi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > > Hi all ! > > > > I''ve got a problem in my application. I''ve written a bug_reports > > > > controller. It is pretty RESTful, there are index, new and create > > > > actions. Everytime I submit a new bug_report, the index action is > > > > called, not the create action, you can see the log here: > > > >http://pastie.org/258857. > > > > My form looks like this: > > > > <fieldset id="bugreport"> > > > > <% form_for @bug_report, :url => bug_reports_path do |f| -%> > > > > <div> > > > > <%= f.text_field :title, :value => "Title" %> > > > > </div> > > > > <div> > > > > <%= f.text_area :body %> > > > > </div> > > > > <div> > > > > <%= f.submit "Submit", :disable_with => ''Submiting...'' %> > > > > </div> > > > > <% end -%> > > > > </fieldset> > > > > Try using the following: > > > > <% form_for(@bug_report) do |f| -%> > > > > Good luck, > > > > -Conrad--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, try the following:
 # POST /bug_reports
  # POST /bug_reports.xml
  def create
    @bug_report = BugReport.new(params[:bug_report])
    respond_to do |format|
      if @bug_report.save
        flash[:notice] = ''BugReport was successfully created.''
        format.html { redirect_to(@bug_report) }
      else
        format.html { render :action => "new" }
      end
    end
  end
On Sun, Aug 24, 2008 at 4:18 AM, Christoph
<chrisi.dibiasi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> Don''t you think the error is somewhere in the code handling the
> request. The form is generated correct, and it also sends the request
> correct to the server, with all parameters, as you can see in the log
> here: http://pastie.org/258857
>
> On 24 Aug., 12:52, "Conrad Taylor"
<conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > Hi, I was able to get it working here without any issues.  I built the
> > application from scratch.  Here''s the new.html.erb:
> > <h1>New bug_report</h1>
> >
> > <% form_for(@bug_report) do |f| %>
> >   <%= f.error_messages %>
> >
> >   <p>
> >     <%= f.label :title %><br />
> >     <%= f.text_field :title %>
> >   </p>
> >   <p>
> >     <%= f.label :body %><br />
> >     <%= f.text_area :body %>
> >   </p>
> >   <p>
> >     <%= f.submit "Create" %>
> >   </p>
> > <% end %>
> >
> > <%= link_to ''Back'', bug_reports_path %>
> >
> > -Conrad
> >
> > On Sun, Aug 24, 2008 at 3:27 AM, Christoph
<chrisi.dibi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> wrote:
> >
> > > No, this doesn''t help. The form seems to be correct
regardless if I
> > > specify the url or not:
> > > <form id="new_bug_report"
class="new_bug_report" method="post"
> > > action="/bug_reports">
> >
> > > On 24 Aug., 12:09, "Conrad Taylor"
<conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > > > On Sun, Aug 24, 2008 at 1:27 AM, Christoph
<chrisi.dibi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> >
> > > wrote:
> >
> > > > > Hi all !
> > > > > I''ve got a problem in my application.
I''ve written a bug_reports
> > > > > controller. It is pretty RESTful, there are index, new
and create
> > > > > actions. Everytime I submit a new bug_report, the index
action is
> > > > > called, not the create action, you can see the log
here:
> > > > >http://pastie.org/258857.
> > > > > My form looks like this:
> > > > > <fieldset id="bugreport">
> > > > > <% form_for @bug_report, :url => bug_reports_path
do |f| -%>
> > > > >  <div>
> > > > >    <%= f.text_field :title, :value =>
"Title" %>
> > > > >  </div>
> > > > >  <div>
> > > > >    <%= f.text_area :body %>
> > > > >  </div>
> > > > >  <div>
> > > > >    <%= f.submit "Submit", :disable_with
=> ''Submiting...'' %>
> > > > >  </div>
> > > > > <% end -%>
> > > > > </fieldset>
> >
> > > > Try using the following:
> >
> > > > <% form_for(@bug_report) do |f| -%>
> >
> > > > Good luck,
> >
> > > > -Conrad
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
On Sun, Aug 24, 2008 at 4:18 AM, Christoph <chrisi.dibiasi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Don''t you think the error is somewhere in the code handling the > request. The form is generated correct, and it also sends the request > correct to the server, with all parameters, as you can see in the log > here: http://pastie.org/258857 >I don''t think that the request is correct because it should look like the following: Processing BugReportsController#create (for 127.0.0.1 at 2008-08-24 04:29:26) [POST] Session ID: BAh7BzoMY3NyZl9pZCIlZDNlNzUzMTBiYTg4OGM5NjI2MWNlNmJmNDdmOWIz MjciCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh c2h7AAY6CkB1c2VkewA=--38e907fd59880233fd4f597c3f76448f80efa3b1 Parameters: {"bug_report"=>{"title"=>"This is a test.", "body"=>"This is a test."}, "commit"=>"Create", "authenticity_token"=>"69184209cf20041cc992c5f33367e7e328932e42", "action"=>"create", "controller"=>"bug_reports"} BugReport Create (0.000863) INSERT INTO "bug_reports" ("created_at", "title", "body", "updated_at") VALUES(''2008-08-24 11:29:26'', ''This is a test.'', ''This is a test.'', ''2008-08-24 11:29:26'') Redirected to http://localhost:3000/bug_reports/0 Completed in 0.01773 (56 reqs/sec) | DB: 0.00086 (4%) | 302 Found [ http://localhost/bug_reports] Your code is performing a GET instead of a POST. Thus, you''re hitting the index action instead of the create action.> > On 24 Aug., 12:52, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, I was able to get it working here without any issues. I built the > > application from scratch. Here''s the new.html.erb: > > <h1>New bug_report</h1> > > > > <% form_for(@bug_report) do |f| %> > > <%= f.error_messages %> > > > > <p> > > <%= f.label :title %><br /> > > <%= f.text_field :title %> > > </p> > > <p> > > <%= f.label :body %><br /> > > <%= f.text_area :body %> > > </p> > > <p> > > <%= f.submit "Create" %> > > </p> > > <% end %> > > > > <%= link_to ''Back'', bug_reports_path %> > > > > -Conrad > > > > On Sun, Aug 24, 2008 at 3:27 AM, Christoph <chrisi.dibi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > No, this doesn''t help. The form seems to be correct regardless if I > > > specify the url or not: > > > <form id="new_bug_report" class="new_bug_report" method="post" > > > action="/bug_reports"> > > > > > On 24 Aug., 12:09, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Sun, Aug 24, 2008 at 1:27 AM, Christoph <chrisi.dibi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > > > > wrote: > > > > > > > Hi all ! > > > > > I''ve got a problem in my application. I''ve written a bug_reports > > > > > controller. It is pretty RESTful, there are index, new and create > > > > > actions. Everytime I submit a new bug_report, the index action is > > > > > called, not the create action, you can see the log here: > > > > >http://pastie.org/258857. > > > > > My form looks like this: > > > > > <fieldset id="bugreport"> > > > > > <% form_for @bug_report, :url => bug_reports_path do |f| -%> > > > > > <div> > > > > > <%= f.text_field :title, :value => "Title" %> > > > > > </div> > > > > > <div> > > > > > <%= f.text_area :body %> > > > > > </div> > > > > > <div> > > > > > <%= f.submit "Submit", :disable_with => ''Submiting...'' %> > > > > > </div> > > > > > <% end -%> > > > > > </fieldset> > > > > > > Try using the following: > > > > > > <% form_for(@bug_report) do |f| -%> > > > > > > Good luck, > > > > > > -Conrad > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Sometimes my router freaks out until I restart the server. It will default to :controller/:action, which has the effect of displaying "index", even though I POST-ed (which should route it to "create"). When stuff goes nutty, I always restart the server. On Aug 24, 2:27 am, Christoph <chrisi.dibi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all ! > I''ve got a problem in my application. I''ve written a bug_reports > controller. It is pretty RESTful, there are index, new and create > actions. Everytime I submit a new bug_report, the index action is > called, not the create action, you can see the log here:http://pastie.org/258857. > My form looks like this: > <fieldset id="bugreport"> > <% form_for @bug_report, :url => bug_reports_path do |f| -%> > <div> > <%= f.text_field :title, :value => "Title" %> > </div> > <div> > <%= f.text_area :body %> > </div> > <div> > <%= f.submit "Submit", :disable_with => ''Submiting...'' %> > </div> > <% end -%> > </fieldset> > > My routes.rb contains this line: map.resources :bug_reports > > And finally, my BugReportsController looks like this: > class BugReportsController < ApplicationController > login_required > def index > @bug_reports = BugReport.all > end > > def new > @bug_report = BugReport.new > end > > def create > @bug_report = BugReport.new params[:bug_report] > if @bug_report.save > flash[:notice] = "Thank you for submitting this bug." > else > flash[:warning] = "Your bug report was not saved. Please try > again." > end > redirect_to root_url > end > end > > This error doesn''t occur in other parts of my app. I really don''t know > why this happens, I hope you can help me. Thank you very much in > advance, > Christoph > > PS: I''ve written a small patch regarding > options_from_collection_for_select. You can find it here:http://rails.lighthouseapp.com/projects/8994/tickets/890-in-options_f.... > I would be happy if someone would give me feedback on this.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you, I don''t know why but routing is correct now. Restarting the server seemed to work. On 25 Aug., 17:49, Mason <sint...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Sometimes my router freaks out until I restart the server. It will > default to :controller/:action, which has the effect of displaying > "index", even though I POST-ed (which should route it to "create"). > > When stuff goes nutty, I always restart the server. > > On Aug 24, 2:27 am, Christoph <chrisi.dibi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi all ! > > I''ve got a problem in my application. I''ve written a bug_reports > > controller. It is pretty RESTful, there are index, new and create > > actions. Everytime I submit a new bug_report, the index action is > > called, not the create action, you can see the log here:http://pastie.org/258857. > > My form looks like this: > > <fieldset id="bugreport"> > > <% form_for @bug_report, :url => bug_reports_path do |f| -%> > > <div> > > <%= f.text_field :title, :value => "Title" %> > > </div> > > <div> > > <%= f.text_area :body %> > > </div> > > <div> > > <%= f.submit "Submit", :disable_with => ''Submiting...'' %> > > </div> > > <% end -%> > > </fieldset> > > > My routes.rb contains this line: map.resources :bug_reports > > > And finally, my BugReportsController looks like this: > > class BugReportsController < ApplicationController > > login_required > > def index > > @bug_reports = BugReport.all > > end > > > def new > > @bug_report = BugReport.new > > end > > > def create > > @bug_report = BugReport.new params[:bug_report] > > if @bug_report.save > > flash[:notice] = "Thank you for submitting this bug." > > else > > flash[:warning] = "Your bug report was not saved. Please try > > again." > > end > > redirect_to root_url > > end > > end > > > This error doesn''t occur in other parts of my app. I really don''t know > > why this happens, I hope you can help me. Thank you very much in > > advance, > > Christoph > > > PS: I''ve written a small patch regarding > > options_from_collection_for_select. You can find it here:http://rails.lighthouseapp.com/projects/8994/tickets/890-in-options_f.... > > I would be happy if someone would give me feedback on this.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---